Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

settings to individually disable css and js compression #204

Open
wants to merge 1 commit into from

1 participant

@theflow

Hi,

I want to have jammit handle js compression using uglifyjs and using sass for the stylesheets, so I don't want YUI to kick in.

This kinda solves the same problem as #189 but this was the simplest thing that works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 30, 2011
  1. @theflow
This page is out of date. Refresh to see the latest.
View
5 lib/jammit.rb
@@ -51,7 +51,8 @@ class << self
:embed_assets, :package_assets, :compress_assets, :gzip_assets,
:package_path, :mhtml_enabled, :include_jst_script, :config_path,
:javascript_compressor, :compressor_options, :css_compressor_options,
- :template_extension, :template_extension_matcher, :allow_debugging
+ :template_extension, :template_extension_matcher, :allow_debugging,
+ :compress_js, :compress_css
attr_accessor :compressors
end
@@ -77,6 +78,8 @@ def self.load_configuration(config_path, soft=false)
@package_path = conf[:package_path] || DEFAULT_PACKAGE_PATH
@embed_assets = conf[:embed_assets] || conf[:embed_images]
@compress_assets = !(conf[:compress_assets] == false)
+ @compress_js = !(conf[:compress_js] == false) && @compress_assets
+ @compress_css = !(conf[:compress_css] == false) && @compress_assets
@gzip_assets = !(conf[:gzip_assets] == false)
@allow_debugging = !(conf[:allow_debugging] == false)
@mhtml_enabled = @embed_assets && @embed_assets != "datauri"
View
4 lib/jammit/compressor.rb
@@ -71,7 +71,7 @@ def compress_js(paths)
else
js = concatenate(paths - jst_paths) + compile_jst(jst_paths)
end
- Jammit.compress_assets ? @js_compressor.compress(js) : js
+ Jammit.compress_js ? @js_compressor.compress(js) : js
end
# Concatenate and compress a list of CSS stylesheets. When compressing a
@@ -80,7 +80,7 @@ def compress_js(paths)
def compress_css(paths, variant=nil, asset_url=nil)
@asset_contents = {}
css = concatenate_and_tag_assets(paths, variant)
- css = @css_compressor.compress(css) if Jammit.compress_assets
+ css = @css_compressor.compress(css) if Jammit.compress_css
case variant
when nil then return css
when :datauri then return with_data_uris(css)
View
9 test/config/assets-compression-config.yml
@@ -0,0 +1,9 @@
+compress_css: false
+
+javascripts:
+ js_test:
+ - fixtures/src/*.js
+
+stylesheets:
+ css_test:
+ - fixtures/src/*.css
View
11 test/unit/test_configuration.rb
@@ -20,6 +20,8 @@ def test_loading_a_nonexistent_file
def test_disabled_compression
Jammit.load_configuration('test/config/assets-compression-disabled.yml')
assert !Jammit.compress_assets
+ assert !Jammit.compress_js
+ assert !Jammit.compress_css
assert !Jammit.gzip_assets
@compressor = Compressor.new
# Should not compress js.
@@ -32,8 +34,17 @@ def test_disabled_compression
assert packed == File.open('test/fixtures/jammed/css_test-uncompressed.css', 'rb') {|f| f.read }
end
+ def test_individually_disabled_compression
+ Jammit.load_configuration('test/config/assets-compression-config.yml')
+ assert Jammit.compress_assets
+ assert Jammit.compress_js
+ assert !Jammit.compress_css
+ end
+
def test_css_compression
assert Jammit.compress_assets
+ assert Jammit.compress_js
+ assert Jammit.compress_css
assert Jammit.gzip_assets
packed = @compressor.compress_css(glob('test/fixtures/src/*.css'))
assert packed == File.read('test/fixtures/jammed/css_test.css')
Something went wrong with that request. Please try again.