babel-plugin-minify-numeric-literals
Example
In
JavaScript
[1000, -20000]
Out
JavaScript
[1e3, -2e4]
Installation
- npm
- Yarn
- pnpm
npm install babel-plugin-minify-numeric-literals --save-dev
yarn add babel-plugin-minify-numeric-literals --dev
pnpm add babel-plugin-minify-numeric-literals --save-dev
Usage
With a configuration file (Recommended)
babel.config.json
{
"plugins": ["minify-numeric-literals"]
}
Via CLI
Shell
babel --plugins minify-numeric-literals script.js
Via Node API
JavaScript
require("@babel/core").transformSync("code", {
plugins: ["minify-numeric-literals"]
});