Skip to content

Instantly share code, notes, and snippets.

@dhiemstra
Created November 8, 2011 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhiemstra/1348501 to your computer and use it in GitHub Desktop.
Save dhiemstra/1348501 to your computer and use it in GitHub Desktop.
cause
require 'sass/importers'
# This monkey patches the SASS filesystem importer to work with files
# that are named *.css.scss. This allows us to be compatible with both
# Rails 3.0.* and Rails 3.1
#
# This should only be loaded in Rails 3.0 apps.
class Sass::Importers::Filesystem
# We want to ensure that all *.css.scss files are loaded as scss files
def extensions_with_css
extensions_without_css.merge('{css.,}scss' => :scss)
end
alias_method_chain :extensions, :css
end
require 'sass/importers'
# This monkey patches the SASS filesystem importer to work with files
# that are named *.css.scss. This allows us to be compatible with both
# Rails 3.0.* and Rails 3.1
#
# This should only be loaded in Rails 3.0 apps.
class Sass::Importers::Filesystem
# We want to ensure that all *.css.scss files are loaded as scss files
def extensions_with_css
extensions_without_css.merge('css.scss' => :scss)
end
alias_method_chain :extensions, :css
end
Since we implemented active_admin the dev environment of everyone on our team became really slow.
Every request took like 60 seconds so i decided to debug it a bit.
After a while i found out that on every request SASS was recompiling all our sass files. Because we split all css nicely we have like 40-50 stylesheets and this took a while to compile.
Debugging more and more inside SASS code i found out the `Sass::Importers::Filesystem#mtime` always returned nil on every found scss file and this resulted in SASS always recompile all the css files.
This only happend to projects that use `app/stylesheets/file.scss` as file format instead of `app/stylesheets/file.css.scss`.
Anyway the fix is simple, see next attached file.
If you want more background info take a look at: `Sass::Importers::Filesystem#possible_files` which is the method generating the `glob` syntax for Sass mtime checker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment