babel-preset-minify
Babel preset for all minify plugins.
Last updated 7 years ago by babeljs .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install babel-preset-minify 
SYNC missed versions from official npm registry.

babel-preset-minify

Babel preset for all minify plugins.

Install

npm install babel-preset-minify --save-dev

Usage

Via .babelrc (Recommended)

.babelrc

{
  "presets": ["minify"]
}

or pass in options -

{
  "presets": [["minify", {
    "mangle": {
      "exclude": ["MyCustomError"]
    },
    "unsafe": {
      "typeConstructors": false
    },
    "keepFnName": true
  }]]
}

Via CLI

babel script.js --presets minify

Via Node API

require("@babel/core").transform("code", {
  presets: ["minify"]
});

Options

Two types of options:

  1. 1-1 mapping with plugin
  2. The same option passed to multiple plugins

1-1 mapping with plugin

  • false - disable plugin
  • true - enable plugin
  • { ...pluginOpts } - enable plugin and pass pluginOpts to plugin
OptionName Plugin DefaultValue
booleans transform-minify-booleans true
builtIns minify-builtins true
consecutiveAdds transform-inline-consecutive-adds true
deadcode minify-dead-code-elimination true
evaluate minify-constant-folding true
flipComparisons minify-flip-comparisons true
guards minify-guarded-expressions true
infinity minify-infinity true
mangle minify-mangle-names true
memberExpressions transform-member-expression-literals true
mergeVars transform-merge-sibling-variables true
numericLiterals minify-numeric-literals true
propertyLiterals transform-property-literals true
regexpConstructors transform-regexp-constructors true
removeConsole transform-remove-console false
removeDebugger transform-remove-debugger false
removeUndefined transform-remove-undefined true
replace minify-replace true
simplify minify-simplify true
simplifyComparisons transform-simplify-comparison-operators true
typeConstructors minify-type-constructors true
undefinedToVoid transform-undefined-to-void true

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.
OptionName Plugins
keepFnName Passed to mangle & deadcode
keepClassName Passed to mangle & deadcode
tdz Passed to builtIns, evaluate, deadcode, removeUndefined

Examples

{
  "presets": [["minify", {
    "evaluate": false,
    "mangle": true
  }]]
}
{
  "presets": [["minify", {
    "mangle": {
      "exclude": ["ParserError", "NetworkError"]
    }
  }]]
}
{
  "presets": [["minify", {
    "keepFnName": true
  }]]
}
// is the same as
{
  "presets": [["minify", {
    "mangle": {
      "keepFnName": true
    },
    "deadcode": {
      "keepFnName": true
    }
  }]]
}

Current Tags

  • 0.6.0-alpha.9                                ...           canary (5 years ago)
  • 0.5.2                                ...           latest (3 years ago)

80 Versions

  • 0.5.2                                ...           3 years ago
  • 0.6.0-alpha.9                                ...           5 years ago
  • 0.5.1                                ...           5 years ago
  • 0.6.0-alpha.8                                ...           5 years ago
  • 0.6.0-alpha.5                                ...           6 years ago
  • 0.6.0-alpha.4                                ...           6 years ago
  • 0.5.0                                ...           6 years ago
  • 0.5.0-alpha.9                                ...           6 years ago
  • 0.5.0-alpha.3cc09dcf                                ...           6 years ago
  • 0.5.0-alpha.beb87b9a                                ...           6 years ago
  • 0.5.0-alpha.5a128fd5                                ...           6 years ago
  • 0.5.0-alpha.2ed85317                                ...           6 years ago
  • 0.5.0-alpha.a24dd066                                ...           7 years ago
  • 0.5.0-alpha.2e0de171                                ...           7 years ago
  • 0.5.0-alpha.89fc69da                                ...           7 years ago
  • 0.5.0-alpha.a28b6b00                                ...           7 years ago
  • 0.5.0-alpha.2ec8ff72                                ...           7 years ago
  • 0.5.0-alpha.01eac1c3                                ...           7 years ago
  • 0.5.0-alpha.5dbc73f7                                ...           7 years ago
  • 0.5.0-alpha.830ce3f1                                ...           7 years ago
  • 0.5.0-alpha.9e447f6d                                ...           7 years ago
  • 0.5.0-alpha.3b1a8f05                                ...           7 years ago
  • 0.5.0-alpha.367cc048                                ...           7 years ago
  • 0.5.0-alpha.36b27d42                                ...           7 years ago
  • 0.5.0-alpha.7ba5821f                                ...           7 years ago
  • 0.5.0-alpha.1cb46b73                                ...           7 years ago
  • 0.5.0-alpha.85c9b6d8                                ...           7 years ago
  • 0.5.0-alpha.6889f45d                                ...           7 years ago
  • 0.5.0-alpha.91ed3622                                ...           7 years ago
  • 0.4.3                                ...           7 years ago
  • 0.5.0-alpha.b5637c57                                ...           7 years ago
  • 0.4.2                                ...           7 years ago
  • 0.5.0-alpha.540d75e7                                ...           7 years ago
  • 0.5.0-alpha.bce578e2                                ...           7 years ago
  • 0.5.0-alpha.18dcfe13                                ...           7 years ago
  • 0.5.0-alpha.9939bca9                                ...           7 years ago
  • 0.5.0-alpha.5f601890                                ...           7 years ago
  • 0.5.0-alpha.34c3efe9                                ...           7 years ago
  • 0.5.0-alpha.9e986477                                ...           7 years ago
  • 0.5.0-alpha.e86a44f1                                ...           7 years ago
  • 0.4.1                                ...           7 years ago
  • 0.5.0-alpha.e9f96ffe                                ...           7 years ago
  • 0.5.0-alpha.8b905991                                ...           7 years ago
  • 0.5.0-alpha.b4285271                                ...           7 years ago
  • 0.5.0-alpha.7b176463                                ...           7 years ago
  • 0.5.0-alpha.55276695                                ...           7 years ago
  • 0.5.0-alpha.b5bafaeb                                ...           7 years ago
  • 0.5.0-alpha.72092d20                                ...           7 years ago
  • 0.4.0                                ...           7 years ago
  • 0.4.0-alpha.caaefb4c                                ...           7 years ago
  • 0.4.0-alpha.f95869d4                                ...           7 years ago
  • 0.4.0-alpha.12994a48                                ...           7 years ago
  • 0.4.0-alpha.4b14df35                                ...           7 years ago
  • 0.4.0-alpha.6546ad11                                ...           7 years ago
  • 0.4.0-alpha.15ca1f11                                ...           7 years ago
  • 0.3.0                                ...           7 years ago
  • 0.3.0-alpha.4143a25b                                ...           7 years ago
  • 0.3.0-alpha.71b0b884                                ...           7 years ago
  • 0.3.0-alpha.6ceffb8d                                ...           7 years ago
  • 0.3.0-alpha.636ae276                                ...           7 years ago
  • 0.3.0-alpha.ab81368f                                ...           7 years ago
  • 0.3.0-alpha.ac576234                                ...           7 years ago
  • 0.3.0-alpha.879f25ec                                ...           7 years ago
  • 0.3.0-alpha.5ee3078e                                ...           7 years ago
  • 0.3.0-alpha.8857f145                                ...           7 years ago
  • 0.3.0-alpha.169f8743                                ...           7 years ago
  • 0.3.0-alpha.6ae655c0                                ...           7 years ago
  • 0.3.0-alpha.d9c99d3f                                ...           7 years ago
  • 0.3.0-alpha.a351eeed                                ...           7 years ago
  • 0.3.0-alpha.cf9a0da2                                ...           7 years ago
  • 0.3.0-alpha.e6a189cd                                ...           7 years ago
  • 0.3.0-alpha.670b24ec                                ...           7 years ago
  • 0.3.0-alpha.7f4dc3d4                                ...           7 years ago
  • 0.3.0-alpha.033d9ab6                                ...           7 years ago
  • 0.3.0-alpha.37064b40                                ...           7 years ago
  • 0.3.0-alpha.9a74dfd1                                ...           7 years ago
  • 0.3.0-alpha.a7421897                                ...           7 years ago
  • 0.3.0-alpha.da60c6b8                                ...           7 years ago
  • 0.2.0                                ...           7 years ago
  • 0.0.0                                ...           9 years ago
Downloads
Total 2
Today 1
This Week 1
This Month 2
Last Day 0
Last Week 1
Last Month 0
Dev Dependencies (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE