UNPKG

1.72 kBMarkdownView Raw
1# babel-minify
2
3Node API and CLI
4
5[![npm](https://img.shields.io/npm/v/babel-minify.svg?maxAge=2592000)](https://www.npmjs.com/package/babel-minify)
6
7Use `babel-minify` if you don't already use babel (as a preset) or want to run it standalone.
8
9## Installation
10
11```sh
12npm install babel-minify --save-dev
13```
14
15## Usage
16
17### Node API
18
19```js
20const minify = require("babel-minify");
21
22const {code, map} = minify("input code", {
23 mangle: {
24 keepClassName: true
25 }
26});
27```
28
29### CLI
30
31```sh
32minify input.js --out-file input.min.js --mangle.keepClassName
33```
34
35## Node API
36
37```js
38const minify = require("babel-minify");
39
40minify(input, minifyOptions, overrides)
41```
42
43### minifyOptions
44
45Refer [babel-preset-minify options](https://github.com/babel/minify/tree/master/packages/babel-preset-minify#options)
46
47### overrides
48
49+ `babel`: Custom babel
50+ `minifyPreset`: Custom minify preset
51+ `inputSourceMap`: Input Sourcemap
52+ `sourceMaps`: [Boolean]
53+ `comments`: [Function | RegExp | Boolean]
54
55## CLI Options
56
57```
58minify input.js [options]
59```
60
61### Simple preset options
62
63For simple options, use `--optionName` in CLI
64
65Refer [preset's 1-1 options](https://github.com/babel/minify/tree/master/packages/babel-preset-minify#1-1-mapping-with-plugin) for the list of options
66
67Example:
68
69```
70minify input.js --mangle false
71```
72
73### Nested preset options
74
75Usage: `--optionName.featureName`
76
77Example:
78
79```sh
80minify input.js --mangle.keepClassName --deadcode.keepFnArgs --outFile input.min.js
81```
82
83Refer the corresponding plugins to know the list of options it takes
84
85### IO options
86
87+ `--out-file path/to/file.min.js`: Output filename. Used only when reading from STDIN / a single input file
88+ `--out-dir path/to/dir`: Output Directory.