Configuring Rails and Angular

As I mentioned earlier, using Angular with the Rails asset pipeline is difficult. In the previous edition of this book, I used Bower to download Angular, and Sprockets (the library that powers Rails’s asset pipeline) automatically brought it in. Angular is not available via Bower, so we have to use Yarn (that’s why we set it up in Chapter 2, Create a Great-Looking Login with Bootstrap and Devise). Configuring the asset pipeline to use Yarn-based libraries and packages is not simple, mainly due to the assumptions the NPM modules Yarn downloads make about the JavaScript environment they are running in. Fortunately, Rails 5.1 introduced Webpacker and that can interoperate with modern JavaScript tools. We used it ...

Get Rails, Angular, Postgres, and Bootstrap, 2nd Edition 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.