Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Commit

Permalink
Added --css-compressor and --js-compressor command line flags
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Oct 11, 2012
1 parent 0fa3cc8 commit 1b194a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions bin/sprockets
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions test/test_sprocketize.rb
Expand Up @@ -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__)
Expand Down

0 comments on commit 1b194a1

Please sign in to comment.