Do you ever find yourself starting up your Rails app, walking away to make a coffee, and coming back only to find it still compiling assets? If so –

Optimizing Your Rails Webpacker Compilation

submited by
Style Pass
2020-09-22 13:49:38

Do you ever find yourself starting up your Rails app, walking away to make a coffee, and coming back only to find it still compiling assets? If so – you’re not alone.

A growing issue for today’s Rails developers is the increasingly frustrating asset compilation times that come with more and more front-end heavy web applications. Today we are going to take a dive into the asset compilation process and how to return those precious minutes back into your life so you can return to doing what you do best: slingin’ code.

The jump to utilizing webpacker for compiling your Rails assets in Rails 6 has presented something of a learning curve to those who had grown comfortable with Sprockets – the previous pipeline implementation packaged by default with earlier Rails versions.

With the zeitgeist of modern web development drifting away from backend rendered templating and towards more frontend heavy Javascript driven “web applications”, the switch to a more robust Javascript compilation engine seems like a natural progression for the maturing framework. Unfortunately, as anyone with Javascript experience will tell you, the npm ecosystem has become rather bloated with libraries, frameworks and dependencies – and after all is said and done both the size of your compiled asset, and the actual time it takes to compile them, can choke your development time and resources.

Leave a Comment