- Install jsbundling-rails
- Swap pack_tag for include_tag
- Import stimulus controllers
- Migrate JS entrypoint
- Remove webpack
- Github Actions
Add to gemfile:
In the terminal, run:
The jsbundling:install command inserts a
Remove webpack's legacy
If your app render multiple layouts, be sure to remove any
Even when you already installed stimulus, run the install command again in your terminal and overwrite any confliction changes. This will import all your existing stimulus controller correctly.
Now, after adding or removing a new stimulus controller you can use a command which will auto-generate the
Move the content from
// old require("channels") //new import "./channels" import "./controllers"
Webpack and its tentacles can finally be removed from the application.
gem 'webpacker', '~> 5.4'
Webpack packages and plugins that accumulated over time can be removed too. For me, this included:
Finally, remove all config and start-up files:
- config/webpack (directory)
If you use Github Actions as a CI/CD make sure to add in an additional build step to run yarn build. Yarn build will trigger the build step defined in your
- name: Build Esbuild run: yarn build
If you use heroku to deploy your application, Heroku will NOT automatically install yarn as it does for Webpack!**
Therefore, we need to explicitly set a node buildpack before ruby. You can do this in the terminal or the Heroku Dashboard.
heroku buildpacks:clear heroku buildpacks:set heroku/nodejs heroku buildpacks:add heroku/ruby