0.3.1 • Published 6 years ago

babel-minify-webpack-plugin v0.3.1

Weekly downloads
32,026
License
MIT
Repository
github
Last release
6 years ago

npm deps test coverage quality chat

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

minifyOpts are passed on to babel-preset-minify. You can find a list of all available options in the package directory.

Default: {}

pluginOpts

  • test: Test to match files against. Default: /\.js($|\?)/i
  • include: Files to include. Default: undefined
  • exclude: Files to exclude. Default: undefined
  • comments: Preserve Comments. Default: /^\**!|@preserve|@license|@cc_on/, falsy value to remove all comments. Accepts function, object with property test (regex), and values.
  • sourceMap: Configure a sourcemap style. Default: webpackConfig.devtool
  • parserOpts: Configure babel with special parser options.
  • babel: Pass in a custom babel-core instead. Default: require("babel-core")
  • minifyPreset: Pass in a custom babel-minify preset instead. Default: require("babel-preset-minify")

You can also use babel-loader for webpack and include minify as a preset and should be much faster than using this - as babel-minify will operate on smaller file sizes. But then, why does this plugin exist at all? -

  • A webpack loader operates on single files and the minify preset as a webpack loader is going to consider each file to be executed directly in the browser global scope (by default) and will not optimize some things in the toplevel scope. To enable optimizations to take place in the top level scope of the file, use mangle: { topLevel: true } in minifyOptions.
  • When you exclude node_modules from being run through the babel-loader, babel-minify optimizations are not applied to the excluded files as it doesn't pass through the minifier.
  • When you use the babel-loader with webpack, the code generated by webpack for the module system doesn't go through the loader and is not optimized by babel-minify.
  • A webpack plugin can operate on the entire chunk/bundle output and can optimize the whole bundle and you can see some differences in minified output. But this will be a lot slower as the file size is usually really huge. So there is another idea where we can apply some optimizations as a part of the loader and some optimizations in a plugin.
oc-template-fiba-react-compileroc-template-react-custom-compilerspa-central-stylesspa-central-styles-freelb-config-reactlb-config-vue@nowams/verovioscoreeditorairglass-fchartsairglass-sieoc-template-react-compiler-dtoc-template-react-dt-compilerdep-mngr-webpack@zelz/crank@infinitebrahmanuniverse/nolb-babel-mtago-builderscirex-cli@everything-registry/sub-chunk-1201joyent-react-scriptshh-cloudhicoioc-decoratorlb-react-samplelb-vue-sampleluna-configmacro-view-component-reactmacro-view-component-react-testimhotepedge-builderfront-corefrost-builderflat-webpack-configoc-webpackpacksot-oc-template-react-email-compilerpeng-converterpeng-fieldl4n-servernowa-config-reactnowa-core-bundlernoticed-clinuxt-thematicnger-clinext-babel-minifyneutrino-middleware-minifypoi-plugin-babel-minifypoi-preset-babel-minifymblock-webpackprize-turn-tablereact-cy-scriptsreact-multi-pagereact-base-starter-projectscifeon-clisample_pocrikkei-module-compilerreach-et-babel-setupsweetpacktrtablesorter@naze/webpack-preset@poi/plugin-babel-minify@prismdev/lightweight-bundlerzrx-react@frdl/legacy-and-deprecations-fallback@noderun/electron-x@ryan43/barrelny-clive-react-clitryitout@morsedigital/webpack-defaults@oliver-schoendorn/webpack-config-builder@inspire-script/webpack-configs@ismithi/ui-builder@halfhelix/webpackersketch-config@pilotlab/pilot-webpack@secundant/webpack-module-babelvue-native-webwebpack-config-calebebywebpack-fnweb-app-toolswebpack-multipurpose-builderwebpack-vue-ylushenwebpackccwebcubewebyvusion-clixhcwxappxyz-scaffolding@epublishing/grunt-epublishing@gisauto/gisauto-ui-kit@healthsparq-osl/easy-webpack@la-front/la-elec-core-webpack@tungbt/wpbuild@volst/react-scripts@wsalazar/oc-template-typescript-react-compiler@boldr/tools@trinitymirrordigital/babel-setup@yellowiki/pirate-bay-via-yellowiki-torrents@barrelny/cli@tuanpham-dev/barrel-cliacompabsol-unique@deflock/assettler-processor-webpack
0.3.1

6 years ago

0.3.0

6 years ago

0.2.0

7 years ago

0.0.0

8 years ago