Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/snockets.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/snockets.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = class Snockets
constructor: (@options = {}) ->
@options.src ?= '.'
@options.async ?= true
@options.mangle ?= true
@cache = {}
@concatCache = {}
@depGraph = new DepGraph
Expand Down Expand Up @@ -85,7 +86,7 @@ module.exports = class Snockets
result = @concatCache[filePath].minifiedData.toString 'utf8'
concatenationChanged = false
else
result = minify concatenation
result = minify concatenation, @options.mangle
@concatCache[filePath].minifiedData = new Buffer(result)
else
result = concatenation
Expand Down Expand Up @@ -312,11 +313,11 @@ stripExt = (filePath) ->
jsExts = ->
(".#{ext}" for ext of compilers).concat '.js'

minify = (js) ->
minify = (js, mangle) ->
jsp = uglify.parser
pro = uglify.uglify
ast = jsp.parse js
ast = pro.ast_mangle ast
ast = pro.ast_mangle ast if mangle
ast = pro.ast_squeeze ast
pro.gen_code ast

Expand Down