I want to upload my customized node_modules to heroku - heroku

I want to upload my customized node_modules to heroku instead of heroku rebuilding node_modules specifically have been dealing with can't resolve ./zlib_bindings so i renamed zlib/lib/zlib.js to zlib/lib/zlib_bindings.js and left it empty which works locally. when rebuilding in heroku i get the error.

Related

Webpack cannot find ./homedir while deploying

I'm trying to deploy app to Heroku, but it fails with [webpack-cli] Error: Cannot find module './homedir'.
When I run ./gradlew build in my console, everything works perfectly, but the moment I'm trying to push into heroku remote it fails with this error.
This is full error stack trace:
https://pastebin.com/wRLBgBXz
The thing was, I forgot to remove cached files from git, after adding node_modules to .gitignore
Also I moved all devDependencies into dependencies because of Heroku installation

app js getting merge conflict when merging branch with master (laravel+vue)

I am developing an application using Laravel and vueJs. During build up the application, the npm run watch command watching all relevant files for changes and recompiling app.js when it detects a change. First time, I created a repository (suppose in github/gitlab/bitbucket etc.) with a master branch and two different branches.
Now, the problem is when we're going to push to the branch or merge with master branch, it's getting so many conflicts in public/js/app.js. I guess, I know the reason. This is because of, during build the application with npm run watch, every changes recompiling the app.js. So, old public/js/app.js in the repository will get the merge conflict in new public/js/app.js. If I ignore the app.js then how the changes impact to the app when multiple developers work at the same time. In this circumstances, what should be the solution when the application is developing by two or more developers and using github,gitlab,gitbucket etc. to merge the codes. Would someone suggest me the correct way please!
Ignore compiled files in your .gitignore as there's no reason to push them to your repository unless you don't have nodejs in your server
.gitignore:
/public/js/app.js
Then run
npm install
npm run prod
In your server when you're ready to deploy
Steps to correct
rm public/js/app.js
echo "/public/js/app.js" >> .gitignore
git commit -m "ignore compiled asset"
git push
npm run watch
I usually ignore all compiled assets in public directory
/public/js/*
/public/css/*
/public/fonts
Because it's cleaner and faster to push (since the compiled assets are huge in size +1MB) to have all dependencies in node_modules and write Javascript as ES6 modules in resources/js or formerly resources/assets/js and same for SASS and CSS
You shouldn't put the compiled files in git, remove the app.js in your public directory from your git repository. Your friend just has to run npm run prod on his machine to get an updated app.js.

Ext-Tidy on Heroku

I'm trying to get the PHP Tidy extension to run on my Heroku instance that I've set up. I've added ext-tidy to my composer.json file and run composer update to update the composer.lock file.
However when I push the changes to Heroku, the build fails as the Heroku buildpack doesn't include the Tidy extension.
Is there a way to get Composer to bundle the Tidy extension so that it gets pushed to Heroku (I'm using a Windows machine so I don't know if this will complicate matters if it is possible)? Or do I need to create a new buildpack with Tidy integrated? If so, I'd appreciate it if someone could point me in the right direction to be able to do this.
Thanks.

Heroku doesnt precompile assets for rails4

The documentation here says that heroku with pre-compile assets during deployement in Rails4.
However ,
I dont see the precompile assets message.
Using thin (1.6.1)
Using twitter-bootstrap-rails (2.2.8)
Using uglifier (2.3.1)
Using will_paginate (3.0.4)
Your bundle is complete! It was installed into ./vendor/bundle
Bundle completed (1.37s)
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
Detected manifest file, assuming assets were compiled locally
-----> Discovering process types
Procfile declares types -> (none)
Default types for Ruby -> console, rake, web, worker
I am facing issues with bootstrap in my app, where the nav bar wont load properly + some other nuances and I think its the asset precompile issue.
I am using Rails4, Ruby2.0
I have assets enabled in application.rb
config.assets.enabled = true
Precompiling manually did not help
heroku run rake assets:precompile
Had this same problem. I had precompiled locally for some reason and then pushed to Heroku.
Saw Heroku give the line "Detected manifest file, assuming assets were compiled locally" which made me realize it wasn't precompiling all the things.
When I did a "git add ." and committed, I saw that it was adding a bunch of public files. Pushing that to Heroku got it to work. So I had to precompile and git add everytime, basically doing Heroku's work for it and making a mess in my public folder. It got the job done, but was a poor fix.
I looked for the "manifest" that heroku mentioned and eventually found a ".sprockets-manifest..." file in the public directory.
Deleted that and Heroku was once again my friend.
Found this question as part of my research so I thought I'd share what I found in case anyone else sees this, or has any elaborational thoughts.
Now I have to go and see if .sprockets-manifest was important to anything else ....
I struggled with the asset pipeline for a while. There seems to be a bit of confusion as to how the asset pipeline works among newer Rubyists. In my experience, this is my workflow to the asset pipeline for Heroku.
Make sure that assets work locally on localhost (required for Heroku)
Delete the public/assets folder in the Rails directory with rm -rf ./public/assets
Make a new assets directory with mkdir public/assets
Run the rake assets:precompile command
You should see a list of assets being precompiled in your command line
Once assets are precompiled, you should commit the changes via the following commands: git add -A then git commit -am "commit message goes here"
Finally, push to heroku via git push heroku master
NOTE: This bears repeating -- make sure your assets work normally on localhost before pushing to Heroku.
Deleting the public/assets folder helped. Also I ran heroku run rake assets:clean.
After that I could see:
----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
The navbar loads fine now !
The message Detected manifest file, assuming assets were compiled locally is shown if there is .sprockets-manifest-*.json or manifest-*.json in public assets. So either removing individual file or whole public/assets works.
The source code for buildpack is here

Should I use Heroku git for source control in addition to production code?

I have created one application using NodeJS, Angular and Express which I want to run at Heroku. Now, Im using Grunt to build the code that are placed in the dist folder and is ready to be deployed and run on Heroku. This would be done by pushing the dist folder in the Heroku git repo.
Now, should i push my source code in Heroku git as well?
If so, how should I seperate it from dist-folder repository? For instance, I dont want Heroku to run npm install each time i push changes to remote repo. And dist folder should not be part of the source code folder in the repository since it is auto generated.
Using a git repository is the only way to push changes to heroku. So yes it is mandatory. Having said that here is what they have to say about it.
Heroku provides the git service primarily for deployment, and the ability to clone from it is offered as a convenience. We strongly recommend you store your code in another git repository such as GitHub and treat that as canonical.
Again there is no way to stop them from doing an npm install on each push. Here is a quote from their getting started guide
Heroku recognizes an app as Node.js by the existence of a package.json. Even if your app has no dependencies, you should still create a package.json that declares a name, version, and empty dependencies in order that it appear as a Node app.
But I suppose that you could download all the dependencies of your app locally, not specify in package.json, push it along with rest of your application and you might trick heroku into thinking that there are no dependencies. Have not tried it myself though.
If you don't want dist folder to be a part of push simply gitignore it.

Resources