forked from rstacruz/sinatra-assetpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement UglifyJS support. Closes rstacruz#18.
- Loading branch information
Showing
7 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Sinatra::AssetPack | ||
class UglifyEngine < Engine | ||
def js(str, options={}) | ||
require 'uglifier' | ||
Uglifier.compile str, options | ||
rescue => e | ||
nil | ||
end | ||
end | ||
|
||
Compressor.register :js, :uglify, UglifyEngine | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(function() { | ||
var kitsch = 1; | ||
var noodle = 2; | ||
var banana = 3; | ||
console.log(noodle, banana); | ||
})(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require File.expand_path('../test_helper', __FILE__) | ||
|
||
class UglifyTest < UnitTest | ||
class App < UnitTest::App | ||
register Sinatra::AssetPack | ||
|
||
assets do | ||
js_compression :uglify, :mangle => true | ||
js :main, '/main.js', [ | ||
'/js/ugly.js' | ||
] | ||
end | ||
end | ||
|
||
def app | ||
App | ||
end | ||
|
||
test "build" do | ||
get '/main.js' | ||
assert !body.include?("noodle") | ||
end | ||
end |