How do *.css in node_modules get loaded?

I’m not supposed to import them in application.js am I? I’d expect them to load automatically within the context of their module

You can import css files using SASS imports in your main application.scss file and reference the css files inside the node module.

Let’s say you have your application.js with something like:

// javascript/packs/application.js
import "../css/application.scss"
// javascript/css/application.scss
@import "some_module/build/somefile.css"

That will emit an application.css pack that contains the css from /node_modules/some_module/build/somefile.css

Hope that makes sense.

1 Like