I'm using uglify-js to minify the source code. I want to remove the console.log statements of the original source code. Is it possible? Or is there any other compressor tool supports this?
I use the code as below in Node.js.
var uglify = require('uglify-js');
var originalSourceCode = 'var name = function(){var str = "test"; return str}; console.log("log data");';
var minifiedCode = uglify.minify(originalSourceCode, {
fromString : true,
mangle: {},
warnings: true
});
console.log(minifiedCode);
The output is:
$node m.js
{ code: 'var name=function(){var a="test";return a};console.log("log data");',
map: 'null' }
In the minified code the console.log isn't removed.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…