Dmitry Shvetsov
1 min readMay 26, 2018

--

Thanks for the nice words and question, Max!

I am using Rails + webpacker on production with 3 projects. I deployed some of the projects with npm, other with yarn and do not experience any problems. You do not have to worry about precompilation when using webpacker. It handles this task internally like sprockets. I highly recommend you to give webpacker a try.

So basically development workflow looks this way:

$ npm install your-favoirite-npm-package --save-prod$ bin/webpack-dev-server$ rails s

and you are done!

Of course, you can add packages directly to package.json file, or use yarn which works with webpacker from the box.

If you are using capistrano for deployment you need no additional steps to use webpacker. You can use rake commands if you prefer to deploy with docker or other deployment tools.

$ rake webpacker:compile RAILS_ENV=production

Webpacker hooks up a new webpacker:compile task to assets:precompile, which gets run whenever you run assets:precompile. If you are not using Sprockets, webpacker:compile is automatically aliased to assets:precompile. Similar to sprockets both rake tasks will compile packs in production mode but will use RAILS_ENVto load configuration from config/webpacker.yml (if available).

if I did not answer your question, let me know.

--

--

Dmitry Shvetsov
Dmitry Shvetsov

No responses yet