I didn't invoke any sass command to "watch" the .sass file changes and recompile them into .css (and concatenate all .css into a giant .css file) But somehow, when I modify any .sass file in the Rails project, and reload the page on a browser, the giant .css file already has the updated content. What is the m开发者_JAVA技巧echanism that does this?
If you have gem 'haml'
in your Gemfile, it's that.
The gem's init.rb file gets run which calls Haml.init_rails
, and you can follow the thread from there pretty easily.
Just in case you're curious how SASS determines if a file should be updated (I was). It checks the mtime of the compiled CSS files (if the compiled file doesn't exist, it obviously creates it). Here's the class that handles checking the staleness of compiled CSS:
https://github.com/nex3/sass/blob/master/lib/sass/plugin/staleness_checker.rb
精彩评论