Guillermo Iguaran

Adventures with Webpack and Rails

Disclaimer: This is not a introductorial post about Webpack or about using Webpack with Rails, if you need an intro I would recommend you to read the Intro to Webpack by Kimberley Cook and if you want to read about how to integrate it with Rails you can read the awesome post by Samuel Mullen about this topic.

I started to play with Webpack a couple of days ago exploring it as alternative to Sprockets in the upcoming version of Rails (5.1? 6.0?), with that on mind I wanted to check how far is possible to go integrating Rails with Webpack without having to change current Rails conventions (e.g folder structure, routes for assets, support for sass/coffee, etc), after of checking many integration projects (react_on_rails, webpack-rails, etc) and based in the configuration suggested by Samuel Mullen in his blog post and many (so many!) other blog posts I was able to get my fork of the TodoMVC app (forked from the Rails + Angular.js + Yarn + Babel version of TodoMVC by Liceth) working:

You can check the history of commits to see how everything was done but I want to leave some additional notes about the process here:

I would continue checking what else can be improved and I’ll update this post with my new findings.

Thanks to Liceth Ovalles for the example app used as base, to Samuel Mullen for the base Webpack configuration, and to Fernando Montoya, Richard Roncancio, Jonathan Alvarez and the other folks in #javascript channel from Colombia-dev that used part of their time to check and help me to improve the Webpack configuration.