babel-minify

✂️ An ES6+ aware minifier based on the Babel toolchain (beta)

MIT 97 个版本
安装
npm install babel-minify
yarn add babel-minify
pnpm add babel-minify
bun add babel-minify
README

babel-minify

Node API and CLI

npm

Use babel-minify if you don't already use babel (as a preset) or want to run it standalone.

Installation

npm install babel-minify --save-dev

Usage

Node API

const minify = require("babel-minify");

const {code, map} = minify("input code", {
  mangle: {
    keepClassName: true
  }
});

CLI

minify input.js --out-file input.min.js --mangle.keepClassName

Node API

const minify = require("babel-minify");

minify(input, minifyOptions, overrides)

minifyOptions

Refer babel-preset-minify options

overrides

  • babel: Custom babel
  • minifyPreset: Custom minify preset
  • inputSourceMap: Input Sourcemap
  • sourceMaps: [Boolean]
  • comments: [Function | RegExp | Boolean]

CLI Options

minify input.js [options]

Simple preset 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

Nested preset options

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

IO options

  • --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.
版本列表
0.6.0-alpha.9 2019-08-15
0.6.0-alpha.8 2019-08-15
0.6.0-alpha.5 2018-10-29
0.6.0-alpha.4 2018-10-29
0.5.2 2022-05-06
0.5.1 2019-08-15
0.5.0-alpha.9 2018-09-23
0.5.0 2018-09-24
0.4.3 2018-05-14
0.4.2 2018-05-14
0.4.1 2018-05-03
0.4.0 2018-04-08
0.3.0 2018-01-31
0.2.0 2017-08-14
0.1.12 2016-07-06
0.1.11 2016-07-03
0.1.10 2016-07-03
0.1.9 2016-07-03
0.1.8 2016-06-30
0.1.7 2016-06-30
0.1.6 2016-06-29
0.1.5 2016-06-29
0.1.4 2016-06-14
0.1.3 2016-06-09
0.1.2 2016-06-09
0.1.1 2016-06-09
0.1.0 2016-06-07
0.0.10 2016-06-07
0.0.7 2016-06-02
0.0.6 2016-06-02
0.0.1 2016-06-02
0.0.0 2016-06-02