Permalink
Browse files

Added --css-compressor and --js-compressor command line flags

  • Loading branch information...
1 parent 0fa3cc8 commit 1b194a1ec375fa8c9e9c1abbdd7df7917d50e458 @josh josh committed Oct 11, 2012
Showing with 19 additions and 0 deletions.
  1. +1 −0 README.md
  2. +8 −0 bin/sprockets
  3. +10 −0 test/test_sprocketize.rb
View
@@ -363,6 +363,7 @@ submit a pull request.
**2.7.0**
+* Added --css-compressor and --js-compressor command line flags
* Added css/js compressor shorthand
* Change default manifest.json filename to be a randomized manifest-16HEXBYTES.json
* Allow nil environment to be passed to manifest
View
@@ -40,6 +40,14 @@ OptionParser.new do |opts|
manifest = Sprockets::Manifest.new(environment, directory)
end
+ opts.on("--css-compressor=COMPRESSOR", "Use CSS compressor") do |compressor|
+ environment.css_compressor = compressor.to_sym
+ end
+
+ opts.on("--js-compressor=COMPRESSOR", "Use JavaScript compressor") do |compressor|
+ environment.js_compressor = compressor.to_sym
+ end
+
opts.on("--noenv", "Disables .sprocketsrc file") do
end
@@ -70,6 +70,16 @@ def teardown
assert File.exist?("#{@dir}/#{digest_path2}")
end
+ test "minify js with uglify" do
+ output = sprockets "-I", fixture_path("default"), "--js-compressor", "uglify", fixture_path("default/gallery.js")
+ assert_equal "var Gallery={};\n", output
+ end
+
+ test "compress css with sass" do
+ output = sprockets "-I", fixture_path("default"), "--css-compressor", "sass", fixture_path("default/gallery.css.erb")
+ assert_equal ".gallery{color:red}\n", output
+ end
+
def sprockets(*args)
script = File.expand_path("../../bin/sprockets", __FILE__)
lib = File.expand_path("../../lib", __FILE__)

0 comments on commit 1b194a1

Please sign in to comment.