Cache CSS if in production

This commit is contained in:
Yuki 2015-07-29 22:29:52 +05:30
parent 47344a5774
commit 5f8dc8a24f
3 changed files with 14 additions and 1 deletions

View file

@ -20,7 +20,13 @@ module ThemeHelper
:compact
end.freeze
erb = ERB.new File.read Rails.root.join 'app/views/user/theme.css.scss.erb'
css = if __THEME_CSS_CACHE.nil?
File.read Rails.root.join 'app/views/user/theme.css.scss.erb'
else
__THEME_CSS_CACHE
end
erb = ERB.new css
sass = Sass::Engine.new erb.result(binding), style: style, cache: false, load_paths: [], syntax: :scss
return sass.render.to_s
end

View file

@ -1,2 +1,5 @@
# Auxiliary config
APP_CONFIG = YAML.load_file(Rails.root.join('config', 'justask.yml'))
# Update rails config for mail
Rails.application.config.action_mailer.default_url_options = { host: APP_CONFIG['hostname'] }

View file

@ -0,0 +1,4 @@
# Cache theme CSS if in production
__THEME_CSS_CACHE = if Rails.env == 'production'
File.read Rails.root.join 'app/views/user/theme.css.scss.erb'
end.freeze