Skip to content

Commit

Permalink
#12 Implement correct minification with sourcemap
Browse files Browse the repository at this point in the history
  • Loading branch information
tormozz48 committed Sep 4, 2015
1 parent e48ccd8 commit 049fb76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"browserify": "10.2.6",
"enb-source-map": "1.7.2",
"enb-source-map": "enb-make/enb-source-map#issue-9",
"uglify-js": "2.4.24",
"vow": "0.4.10",
"vow-node": "0.3.0"
Expand Down
9 changes: 6 additions & 3 deletions techs/browser-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ module.exports = require('enb/lib/build-flow').create()
var file = new File(this.node.resolvePath(this._target), { sourceMap: this._sourcemap }),
needWrapIIFE = this._iife,
needToAddComments = !this._compress,
compressOptions = { fromString: true };
compressOptions = { fromString: true},
compressed;

sources.forEach(function (source) {
needToAddComments && file.writeLine('/* begin: ' + source.relPath + ' */');
Expand All @@ -89,9 +90,11 @@ module.exports = require('enb/lib/build-flow').create()
return minify(file.render(), compressOptions).code;
}

file._content = minify(file._content.join(EOL), compressOptions).code;
compressOptions.inSourceMap = file.getSourceMap();
compressOptions.outSourceMap = 'minified.js.map';

return Utils.joinContentAndSourceMap(file._content, file._map);
compressed = minify(file.getContent(), compressOptions);
return Utils.joinContentAndSourceMap(compressed.code, compressed.map);
}, this);
})
.methods({
Expand Down

0 comments on commit 049fb76

Please sign in to comment.