I use @import‘d partial sheets to organize my css/sass:
/app
/assets
/stylesheets
_constants.sass
_layout.sass
...
app.css.sass
app.css.sass:
@import _constants.sass
// basic styles
@import _layout.sass
@import ...
app.css.sass has an @import rule for _layout.sass, which allows me to share mixins and variables amongst the raw sass files before they’re complied down into app.css
The problem is that Rails doesn’t recognize changes to the @import‘d partials (_layout.sass) and won’t regenerate app.css until I make a change to the actual app.css.sass file itself. This dramatically slows down my workflow and means I have to add/remove blank lines from app.css.sass to see changes. Never had this problem in 3.0.
Is there a way of forcing sass assets to regenerate on every server request in development?
Using a
depend_ondirective may do what you require. This makes the given file a dependency of the base file (so the base file is regenerated when the dependency changes), but doesn’t include it in the bundle.For example:
See this sass and sprockets blog post as well as the sprockets documentation (especially the directives section).