babel-preset-babili
Babel preset for all minify plugins.
Install
npm install --save-dev babel-preset-babili
Usage
Via .babelrc
(Recommended)
.babelrc
{
"presets": ["babili"]
}
or pass in options -
{
"presets": [["babili", {
"mangle": {
"blacklist": ["MyCustomError"]
},
"unsafe": {
"typeConstructors": false
},
"keepFnName": true
}]]
}
Via CLI
babel script.js --presets babili
Via Node API
require("babel-core").transform("code", {
presets: ["babili"]
});
Options
Two types of options:
- 1-1 mapping with plugin
- The same option passed to multiple plugins
1-1 mapping with plugin
false
- disable plugintrue
- enable plugin{ ...pluginOpts }
- enable plugin and pass pluginOpts to plugin
The same option passed to multiple plugins
- When multiple plugins require the same option, it's easier to declare it in one place. These options are passed on to two or more plugins.
Examples
{
"presets": [["babili", {
"evaluate": false,
"mangle": true
}]]
}
{
"presets": [["babili", {
"mangle": {
"blacklist": ["ParserError", "NetworkError"]
}
}]]
}
{
"presets": [["babili", {
"keepFnName": true
}]]
}
{
"presets": [["babili", {
"mangle": {
"keepFnName": true
},
"deadcode": {
"keepFnName": true
}
}]]
}