This package is not maintained anymore. Be aware!
An Uglifyjs2 plugin for Metalsmith.
npm install --save metalsmith-uglifyjs
If you haven't checked out Metalsmith before, head over to their website and check out the documentation.
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
}
}
}))
You can check the tests out to see some usage examples.
A multimatch expression that can be used to limit the files
that will be uglified. Default is ["**/*.js", "!**/*.min.js"]
Please note that IT IS YOUR JOB to EXCLUDE
already minified files using src
setting if you are using a customized name convention.
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)
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
A boolean, if true original files will be deleted, if false original files will be kept as-is. Default: false
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
A valid config that will be passed to uglifyjs. Please see here for your options. Default:
uglifyOptions: {
mangle: false,
compress: {}
}
This means use default compress options and do not mangle.
Just open an issue or prepare a pull request.