Merge pull request #2244 from vikhyat/css-import

Site Customization @import fixes
This commit is contained in:
Sam
2014-04-10 07:01:34 +10:00
11 changed files with 61 additions and 41 deletions

View File

@ -14,12 +14,26 @@ class SiteCustomization < ActiveRecord::Base
end
def compile_stylesheet(scss)
# Get the sprockets environment. In production Rails.application.assets is a
# Sprockets::Index instead of Sprockets::Environment, there is no cleaner way
# to get the environment from the index.
env = Rails.application.assets
if env.is_a?(Sprockets::Index)
env = env.instance_variable_get('@environment')
end
context = env.context_class.new(env, "custom.scss", "app/assets/stylesheets/custom.scss")
::Sass::Engine.new(scss, {
syntax: :scss,
cache: false,
read_cache: false,
style: :compressed,
filesystem_importer: DiscourseSassImporter
filesystem_importer: DiscourseSassImporter,
sprockets: {
context: context,
environment: context.environment
}
}).render
rescue => e