Get rid of plugins.css, inject it using DiscourseSassImporter.

This commit is contained in:
Vikhyat Korrapati 2014-04-09 19:36:42 +05:30
parent 8c129e480a
commit 33307a50b3
7 changed files with 21 additions and 18 deletions

View file

@ -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";

View file

@ -1,2 +1,5 @@
@import "common";
@import "mobile/*";
/* This file doesn't actually exist, it is injected by DiscourseSassImporter. */
@import "plugins_mobile";

View file

@ -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
%>

View file

@ -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
%>

View file

@ -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 %>

View file

@ -68,7 +68,7 @@ module Discourse
path =~ /assets\/images/ && !%w(.js .css).include?(File.extname(filename))
end]
config.assets.precompile += ['vendor.js', 'common.css', 'desktop.css', 'mobile.css', 'admin.js', 'admin.css', 'shiny/shiny.css', 'preload_store.js', 'browser-update.js', 'embed.css', 'break_string.js', 'plugins.css', 'plugins_mobile.css']
config.assets.precompile += ['vendor.js', 'common.css', 'desktop.css', 'mobile.css', 'admin.js', 'admin.css', 'shiny/shiny.css', 'preload_store.js', 'browser-update.js', 'embed.css', 'break_string.js']
# Precompile all defer
Dir.glob("#{config.root}/app/assets/javascripts/defer/*.js").each do |file|

View file

@ -35,7 +35,20 @@ class DiscourseSassImporter < Sass::Importers::Filesystem
end
def find(name, options)
if name =~ GLOB
if name == "plugins" || name == "plugins_mobile"
if name == "plugins"
stylesheets = DiscoursePluginRegistry.stylesheets
elsif name == "plugins_mobile"
stylesheets = DiscoursePluginRegistry.mobile_stylesheets
end
contents = ""
stylesheets.each {|css| contents << File.read(css) }
Sass::Engine.new(contents, options.merge(
filename: "#{name}.scss",
importer: self,
syntax: :scss
))
elsif name =~ GLOB
nil # globs must be relative
else
engine_from_path(name, root, options)