A very lightweight Metalsmith uglifyjs2 plugin
npm install metalsmith-uglifyjsmetalsmith-uglifyjs
===============







An Uglifyjs2 plugin for Metalsmith.
``sh`
npm install --save metalsmith-uglifyjs
If you haven't checked out Metalsmith before, head over to their website and check out the
documentation.
`js
var uglifyjs = require("metalsmith-uglifyjs");
metalsmith
.use(uglifyjs({
src: ["/.js", "!/.min.js"],
target: function(inFile) { return inFile + ".customMinFileName.js"; },
deleteSources: true,
uglifyOptions: {
mangle: true,
compress: {
unused: false,
warnings: true
}
}
}))
`
Please note that IT IS YOUR JOB to EXCLUDE
already minified files using src setting if you are using a customized name convention.$3
A function that takes a file name as input and expected to return minified file name as output. Default
function adds .min. before extension. _(i.e. a.js -> a.min.js)_$3
If true, then compressed JS will be written into the same files that were compressed. The target
and deleteSources options are discarded in this case.Default:
false$3
A boolean, if true original files will be deleted, if false original files will be kept as-is. Default: false
$3
A boolean flag, when set to false this whole stuff will be disabled. This can be used to disable uglify based on
some variable. (e.g. Don't run this on dev but run this on prod.) Default:
true$3
A valid config that will be passed to uglifyjs. Please see here for your options. Default:
`js
uglifyOptions: {
mangle: false,
compress: {}
}
``