Search code examples
webpackruby-on-rails-5webpacker

Webpacker in Rails 5 takes a long time to compile not that many files. How can I see what it's doing?


[Webpacker] Compiling…

It takes several seconds (6.2 seconds) to compile any of my changes to javascript files. It's really slowing my JS development down.

Is there any way to see what Webpacker in Rails is doing and which files it's spending most of its time on? It also be good if it could show me how much time each npm library was using.

I can manually run the rails webpacker:compile command but there doesn't seem to be any verbose mode on that.

Any help is appreciated, thanks!


Solution

  • I should've RTFM:

    If you want to use live code reloading, or you have enough JavaScript that on-demand compilation is too slow, you'll need to run ./bin/webpack-dev-server or ruby ./bin/webpack-dev-server. Windows users will need to run these commands in a terminal separate from bundle exec rails s. This process will watch for changes in the app/javascript/packs/*.js files and automatically reload the browser to match.

    Running ./bin/webpack-dev-server uses live code reloading and is super fast!