世間では GW ですが、皆さんいかがお過ごしでしょうか。こちらは仕事も落ち着いてきたため、直近のプロジェクトでそこそこ時間を使う羽目になった Webpacker についてのブログ記事を書くことにしました。 はじめに Ruby on Rails では Sprockets というモジュール(?)によって、JavaScript, CSS, 画像などのアセットを管理する事が出来ます。これは Rails 独自の仕組みであり、それによる問題点なども目立つようになったため、フロントエンド界隈で広く使われている Webpack を使いたいという要望は以前からあったようです。(その辺りの経緯などは、検索すれば色々出てくるので、ここでは記載しません。) そうした要望に応えるものが Webpacker で、簡単に言うと Webpack の機能を Rails に組み込んだもので、使う側からすると主に以下の2つの機