You spend too much time to deploy your rails project especially on the assets:precompile
step, or maybe sometimes you see the following error during the assets precompilation:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
So for sure, this short article will help you to have 50% improvement only with some minor changes.
If you’re using webpacker
in your project, the assets:precompile
consists of two stages; we will call these two stages, sprockets
and webpacker
. Now we want to execute these two stages separately to find out which one is your problem.
Run sprockets
stage:
WEBPACKER_PRECOMPILE=false rake assets:precompile
and then run webpacker
building stage:
rake webpacker:compile
NOTE:_ If you want to analyze the performance of the above commands in production mode, pass
_RAILS_ENV=production_
as an environment variable to both of them._
If the webpacker
is your main problem, keep reading and we are going to investigate and resolve the issue. There is a way to see the details of webpacker
compile command, in order to that we should use webpack
itself instead of webpacker
:
./bin/webpack --progress
#deployment #webpacker #ruby-on-rails #webpack