rails bootstrap-sass assets compilation error - undefined variable alert-padding

Don't know why but for me it helped to put into assets.rb this line

Rails.application.config.assets.precompile += [/^[-_a-zA-Z0-9]*\..*/]

Initially I had the Sass::SyntaxError: Undefined variable: "$alert-padding". problem with this line

Rails.application.config.assets.precompile += [/.*\.css/] 

But after I changed it to the first one the problem was solved and everything worked in production.


My specific problem turned out to be some code hiding in application.rb...

how I found it

I added puts config.assets.precompile.inspect to config/environments/production.rb and marvelled at the regex it output. Then I searched the codebase for "config.assets.precompile" and lo, in application.rb, there was:

config.assets.precompile << /(^[^_\/]|\/[^_])[^\/]*$/
...
config.assets.precompile += ["*.js", "*.css", "jquery-migrate-rails.js"]

which was causing the problem. (I'm slightly puzzled as I've triple checked those regexes and they shouldn't be picking up _alerts.scss... but lets gloss over that and focus on the fact that removing those lines fixed it)

Maybe this will help someone else...