mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-22 10:17:48 +01:00
Cache CSS if in production
This commit is contained in:
parent
47344a5774
commit
5f8dc8a24f
3 changed files with 14 additions and 1 deletions
|
@ -20,7 +20,13 @@ module ThemeHelper
|
||||||
:compact
|
:compact
|
||||||
end.freeze
|
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
|
sass = Sass::Engine.new erb.result(binding), style: style, cache: false, load_paths: [], syntax: :scss
|
||||||
return sass.render.to_s
|
return sass.render.to_s
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
|
# Auxiliary config
|
||||||
APP_CONFIG = YAML.load_file(Rails.root.join('config', 'justask.yml'))
|
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'] }
|
Rails.application.config.action_mailer.default_url_options = { host: APP_CONFIG['hostname'] }
|
||||||
|
|
4
config/initializers/13_theme.rb
Normal file
4
config/initializers/13_theme.rb
Normal 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
|
Loading…
Reference in a new issue