mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Merge pull request #2244 from vikhyat/css-import
Site Customization @import fixes
This commit is contained in:
@@ -8,3 +8,6 @@
|
||||
@import "common/components/*";
|
||||
@import "common/admin/*";
|
||||
@import "common/input_tip";
|
||||
|
||||
/* This file doesn't actually exist, it is injected by DiscourseSassImporter. */
|
||||
@import "plugins";
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
@import "common";
|
||||
@import "mobile/*";
|
||||
|
||||
/* This file doesn't actually exist, it is injected by DiscourseSassImporter. */
|
||||
@import "plugins_mobile";
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<%
|
||||
# TODO this is very tricky, we want to add a dependency here on files that may not yet exist
|
||||
# otherwise in dev we are often stuck nuking the tmp/cache directory
|
||||
DiscoursePluginRegistry.stylesheets.each do |css|
|
||||
require_asset(css)
|
||||
end
|
||||
%>
|
||||
@@ -1,7 +0,0 @@
|
||||
<%
|
||||
# TODO this is very tricky, we want to add a dependency here on files that may not yet exist
|
||||
# otherwise in dev we are often stuck nuking the tmp/cache directory
|
||||
DiscoursePluginRegistry.mobile_stylesheets.each do |css|
|
||||
require_asset(css)
|
||||
end
|
||||
%>
|
||||
@@ -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
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
<%- unless SiteCustomization.override_default_style(session[:preview_style]) %>
|
||||
<% if mobile_view? %>
|
||||
<%= stylesheet_link_tag "mobile" %>
|
||||
<%= stylesheet_link_tag "plugins_mobile" %>
|
||||
<% else %>
|
||||
<%= stylesheet_link_tag "desktop" %>
|
||||
<%= stylesheet_link_tag "plugins" %>
|
||||
<% end %>
|
||||
<%- end %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user