mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 11:48:26 -06:00
PERF: workaround aweful sass compiling perf with HUGE css files
This commit is contained in:
parent
f602c568e2
commit
d969958b18
@ -34,12 +34,21 @@ task 'assets:precompile:before' do
|
|||||||
class SassCompressor
|
class SassCompressor
|
||||||
def evaluate(context, locals, &block)
|
def evaluate(context, locals, &block)
|
||||||
::Sprockets.cache_compiled("sass", data) do
|
::Sprockets.cache_compiled("sass", data) do
|
||||||
::Sass::Engine.new(data, {
|
# HACK, SASS compiler will degrade to aweful perf with huge files
|
||||||
:syntax => :scss,
|
# Bypass if larger than 200kb, ensure assets are minified prior
|
||||||
:cache => false,
|
if context.pathname &&
|
||||||
:read_cache => false,
|
context.pathname.to_s =~ /.css$/ &&
|
||||||
:style => :compressed
|
data.length > 200.kilobytes
|
||||||
}).render
|
puts "Skipped minifying #{context.pathname} cause it is larger than 200KB, minify in source control or avoid large CSS files"
|
||||||
|
data
|
||||||
|
else
|
||||||
|
::Sass::Engine.new(data, {
|
||||||
|
:syntax => :scss,
|
||||||
|
:cache => false,
|
||||||
|
:read_cache => false,
|
||||||
|
:style => :compressed
|
||||||
|
}).render
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -48,7 +57,7 @@ task 'assets:precompile:before' do
|
|||||||
|
|
||||||
def evaluate(context, locals, &block)
|
def evaluate(context, locals, &block)
|
||||||
::Sprockets.cache_compiled("uglifier", data) do
|
::Sprockets.cache_compiled("uglifier", data) do
|
||||||
Uglifier.new(:comments => :none).compile(data)
|
Uglifier.new(:comments => :none).compile(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user