$ cnpm install babel-minify
Node API and CLI
Use babel-minify if you don't already use babel (as a preset) or want to run it standalone.
npm install babel-minify --save-dev
const minify = require("babel-minify");
const {code, map} = minify("input code", {
mangle: {
keepClassName: true
}
});
minify input.js --out-file input.min.js --mangle.keepClassName
const minify = require("babel-minify");
minify(input, minifyOptions, overrides)
Refer babel-preset-minify options
babel: Custom babelminifyPreset: Custom minify presetinputSourceMap: Input SourcemapsourceMaps: [Boolean]comments: [Function | RegExp | Boolean]minify input.js [options]
For simple options, use --optionName in CLI
Refer preset's 1-1 options for the list of options
Example:
minify input.js --mangle false
Usage: --optionName.featureName
Example:
minify input.js --mangle.keepClassName --deadcode.keepFnArgs --outFile input.min.js
Refer the corresponding plugins to know the list of options it takes
--out-file path/to/file.min.js: Output filename. Used only when reading from STDIN / a single input file--out-dir path/to/dir: Output Directory.Copyright 2013 - present © cnpmjs.org | Home |