So I had enough of the debacle, so I put “bootstrap” 5.3.3 into the gemfile, and “dartsass-rails” into the gemfile. Then this script into the app:
module PrepareScss
ASSETS = %w(app/assets/stylesheets app/assets/images app/assets/fonts)
OUTPUT = "app/assets/builds/application.css"
INFILE = "app/assets/stylesheets/appstyle.scss"
def self.run
return if FileUtils.uptodate?(OUTPUT, Find.find(*ASSETS).to_a)
search = [ File.join(Gem.loaded_specs["bootstrap"].full_gem_path,
"assets/stylesheets") ]
css = Sass.compile INFILE, source_map: false, load_paths: search
css = AutoprefixerRails.process(css.css).css
File.write OUTPUT, css
end
end
Sass.compile
appears to need a working Linux [emu] for now (due to the dart plague), otherwise one can also call the exe/sass
executable instead.
And call it:
class ApplicationController < ActionController::Base
before_action do
if ENV["RAILS_ENV"] == "development"
::PrepareScss.run
end
end
...
Some requires are needed:
require 'find'
require 'sass-embedded'
require 'autoprefixer-rails'
And that seems to work.
Obviousely a node
executable must be present. But no need for any npx or node_modules. No need for watcher processes, bin/dev, bin/setup or whatever else.
End of story, love it.