Skip to content

Commit 25ce4ef

Browse files
committed
Compress sass files with a single pass by moving the compression step to
the generation step and only compressing files with 3 ore more lines in them.
1 parent 080d325 commit 25ce4ef

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lib/sass/rails/compressor.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ module Sass
44
module Rails
55
class CssCompressor
66
def compress(css)
7-
Sass::Engine.new(css,
8-
:syntax => :scss,
9-
:cache => false,
10-
:read_cache => false,
11-
:style => :compressed).render
7+
if css.count("\n") > 2
8+
Sass::Engine.new(css,
9+
:syntax => :scss,
10+
:cache => false,
11+
:read_cache => false,
12+
:style => :compressed).render
13+
else
14+
css
15+
end
1216
end
1317
end
1418
end

lib/sass/rails/railtie.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ module SassContext
6666

6767
initializer :setup_compression, :group => :all do |app|
6868
if app.config.assets.compress
69-
# Use sass's css_compressor
69+
app.config.sass.style = :compressed
7070
app.config.assets.css_compressor = CssCompressor.new
7171
end
7272
end

0 commit comments

Comments
 (0)