diff --git a/lib/Watchers/Script.coffee b/lib/Watchers/Script.coffee index a38873a..8e0b625 100644 --- a/lib/Watchers/Script.coffee +++ b/lib/Watchers/Script.coffee @@ -7,6 +7,7 @@ minimatch = require 'minimatch' esprima = require 'esprima' UglifyJS = require 'uglify-js' +flatten = require 'flatten-source-map' class ScriptWatcher extends SourcemapWatcher constructor: (@config)-> @@ -51,11 +52,18 @@ class ScriptWatcher extends SourcemapWatcher ScriptWatcher.renderers[extension].call(this, code, path) minify: ({content, sourceMap})-> - result = UglifyJS.minify content, - fromString: true - inSourceMap: sourceMap - outSourceMap: "app.js.map" - {content: result.code, sourceMap: result.map} + if typeof sourceMap isnt "undefined" + generatedMap = flatten(sourceMap) + + result = UglifyJS.minify content, + fromString: true + inSourceMap: generatedMap + outSourceMap: "app.js.map" + else + result = UglifyJS.minify content, + fromString: true + + {content: result.code, sourceMap: generatedMap || ""} concat: (_)-> res = super _ # {content, sourceMap} diff --git a/package.json b/package.json index 5b4dd62..f39e75f 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "coffee-script": "^1.8.0", "debug": "^2.1.1", "esprima": "^1.2.2", + "flatten-source-map": "0.0.1", "glob": "^4.0.2", "graceful-fs": "^3.0.2", "jade": "^1.3.1",