Plugins

来源:互联网 发布:软件随想录读后感 编辑:程序博客网 时间:2024/05/17 04:44

?> plugins customize the webpack build process in a variety of ways. This page discusses using existing plugins, however if you are interested in writing your own please visit Writing a Plugin.

plugins

array

A list of webpack plugins. For example, when multiple bundles share some of the same dependencies, the CommonsChunkPlugin could be useful to extract those dependencies into a shared bundle to avoid duplication. This could be added like so:

plugins: [  new webpack.optimize.CommonsChunkPlugin({    ...  })]

A more complex example, using multiple plugins, might look something like this:

// importing plugins that do not come by default in webpackvar ExtractTextPlugin = require('extract-text-webpack-plugin');var DashboardPlugin = require('webpack-dashboard/plugin');// adding plugins to your configurationplugins: [  // build optimization plugins  new webpack.optimize.CommonsChunkPlugin({    name: 'vendor',    filename: 'vendor-[hash].min.js',  }),  new webpack.optimize.UglifyJsPlugin({    compress: {      warnings: false,      drop_console: false,    }  }),  new ExtractTextPlugin({    filename: 'build.min.css',    allChunks: true,  }),  new webpack.IgnorePlugin(/^\.\/locale$/, [/moment$/]),  // compile time plugins  new webpack.DefinePlugin({    'process.env.NODE_ENV': '"production"',  }),  // webpack-dev-server enhancement plugins  new DashboardPlugin(),  new webpack.HotModuleReplacementPlugin(),]
0 0
原创粉丝点击