So I have a project with page-specific styles and css. I've put those files into their own directory assets/#{type}/page-specific/
and I'm attempting to write a regex rule to inform the precompiler to do it's thing with them.
This is working great for the JS side of the house, but the css is proving more difficult.
# page specific style files:
app/assets/stylesheets/page-specific/something.css.sass
app/assets/stylesheets/page-specific/default.css
app/assets/stylesheets/page-specific/home.css.scss
I was working with this regex in my config/initializers/assets.rb
file:
Rails.application.config.assets.precompile << /(page-specific\/[^(css)]+.css)/
The problem being that the [^(css)]
section doesn't do quite what I want, as it will filter out anything that has a c or s in it. What I'm really looking for is a way to match up to the whole string "css" and stop there.
Also, I know the conventional wisdom would be to simply write the styles in a way that you wouldn't need page-specific stylesheets in favor of application.css containing the whole of the stylesheets. I agree. However this is a very large code base and there is a lot of time pressure to bring this Rails upgrade home, and there isn't time to spend analyzing and refactoring things of this nature.
I've tried just making the delimiter directive [^\.]
to stop at the first dot, however this blows up on some vendor stylesheets that use the dot as a delimiter such as jquery.treeview.css.sass
. Obviously I can just change the file names, but we are a large team that's growing, and I want to make the rule as flexible as possible so we don't have files sneak in that will blow up in production when they don't get precompiled.