一个用于babel-minify的 webpack 插件 - 基于 babel 的 minifier
npm install babel-minify-webpack-plugin --save-dev
// webpack.config.js
const MinifyPlugin = require("babel-minify-webpack-plugin");
module.exports = {
  entry: //...,
  output: //...,
  plugins: [
    new MinifyPlugin(minifyOpts, pluginOpts)
  ]
}
###
minifyOpts 被传递给 babel-preset-minify。 你可以在包目录中找到所有可用的选项。
Default: {}
test: Test to match files against. Default: /\.js($|\?)/iinclude: Files to include. Default: undefinedexclude: Files to exclude. Default: undefinedcomments: 保留注释。默认:/^\**!|@preserve|@license|@cc_on/,falsy 值将移除所有注释。可以接受函数,带有属性匹配(正则)的对象和值。sourceMap: Configure a sourcemap style. 默认:webpackConfig.devtoolparserOpts: 配置具有特殊解析器选项的 babel。babel: 传入一个自定义的 babel-core。默认:require("babel-core")minifyPreset: 传入一个自定义 babel-minify preset 代替原来的。默认:require("babel-preset-minify")你也可以在webpack中使用babel-loader,引入 minify 作为一个预设并且应该运行的更快 - 因为 babel-minify 将运行在更小的文件。但是,这个插件为什么还存在呢?
mangle: { topLevel: true }。node_modules 不通过 babel-loader 运行时,babel-minify 优化不会应用于被排除的文件,因为它们不会通过 minifier。| Boopathi Rajaa | Juho Vepsäläinen | Joshua Wiens | Kees Kluskens | Sean Larkin |