How to automatically compile scss in css with a resource pipeline in Rails 3.1?

The new rails 3.1 asset traffic confused me. In rails 3.0.x, using sass gem, my global css file was updated while editing .scss files. But in rails 3.1 this no longer works. It seems I need to run the rake task to update my css files whenever I modify .scss files. I feel like I misunderstand something about the pipeline of a new asset, but I don’t know what it is. Can someone give a solution or explanation for this problem? Thank.

+5
source share
3 answers

These are two possible reasons. I assume that you are in development mode and download all the gems.

1. Config

In development mode, files are compiled on demand and cached until any changes are made. You must get the new 3.1 configuration settings set in the correct files, or this may not work as expected.

Check out the Rails tutorial on upgrading .

2. Extensions

Another gets the extensions in the correct order. For scss to be file.css.scss. This tells Sprockets to first parse files as scss, and also have the css extension. If you had .erb at the end - file.css.scss.erb- then erb is processed first, then scss.

, . .

+6
0

For me, this problem is solved very easily. I simply deleted all the precompiled * .css files from the assets / style sheets and left all the * .scss files. Rails worked fine with * .scss directly, without prior compilation.

0
source

All Articles