Serving CSS via Webpack
We’ve been writing CSS in files located in app/assets/stylesheets. Rails will find whatever css files are there, bundle them all up together, and make the combined CSS available to your views. If you want to use modern CSS tools or techniques, such as CSS modules or Post CSS,[126][127] it’s not easy or possible to use them with the CSS that Rails serves up.
The part of Rails that handles CSS is called Sprockets, and while new gems are always being produced to give Sprockets new abilities, the state of the art in CSS is part of the JavaScript ecosystem and available via Webpack. Prior to Rails 5.1, setting up Webpack was extremely difficult. But as we learned in Chapter 13, Task H: Entering Additional Payment Details ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access