Sprockets 4 and possibility to pass stylesheets folder handling to dart sass

414 Views Asked by At

Is there anything in Sprockets 4 to use like Propshaft has? config.assets.excluded_paths

You can however exempt directories that have been added through the config.assets.excluded_paths. This is useful if you're for example using app/assets/stylesheets exclusively as a set of inputs to a compiler like Dart Sass for Rails, and you don't want these input files to be part of the load path. (Remember you need to add full paths, like Rails.root.join("app/assets/stylesheets")).

So it can be used together with Dartsass-rails Configuring Builds and therefore everything under stylesheets asset pipeline handled by dart sass?

1

There are 1 best solutions below

0
Goaul On

Figured it out:

  1. when some specific css files not set for config.assets.precompile (then sprockets not handles them);
  2. use dartsass for those extra files:
Rails.application.config.dartsass.builds = {
      "application.scss"    => "application.css",
      "example.scss"        => "example.css"
    }
  1. in manifest.js is added build folder, file content:
// app/assets/config/manifest.js

//= link_tree ../images
//= link application.js
//
//= link_tree ../builds
//

So the asset pipeline works like this: dartsass compiles scss files to css and puts in /build folder and sprocets uses it.