1. babel-minify
✂️ An ES6+ aware minifier based on the Babel toolchain (beta)
babel-minify
Package: babel-minify
Created by: babel
Last modified: Mon, 13 Jun 2022 04:00:16 GMT
Version: 0.5.2
License: MIT
Downloads: 68,077
Repository: https://github.com/babel/minify/tree/master/packages/babel-minify

Install

npm install babel-minify
yarn add babel-minify

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.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin