Configuring Webpacker

A Rails 6.1 app installs Webpacker as part of the default app creation; however, you need to make some configuration changes up front to install Hotwire, and make sure that CSS and TypeScript are properly integrated.

Webpacker is a Rails gem, so the default install puts it into your Gemfile:

 gem "webpacker"

As I write this, Webpacker 6.0 is in beta. This book uses Beta 6—hopefully it will be released by the time you read this.

Webpacker creates a number of local configuration files, including the package.json manifest of JavaScript libraries to use, and then retrieves those JavaScript libraries using the Yarn package manager.[24]

The default installation of Webpacker does not integrate with TypeScript or with CSS libraries. ...

Get Modern Front-End Development for Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.