使用插件可以扩展 Webpack 的功能,比如 BellOnBundlerErrorPlugin
会在你构建过程出现错误时发出通知
内置插件
内置插件可以直接配置实用
// webpack should be in the node_modules directory, install if not.
var webpack = require("webpack");
module.exports = {
plugins: [
new webpack.ResolverPlugin([
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
], ["normal", "loader"])
]
};
第三方插件
第三方插件必须先安装才能使用
npm install component-webpack-plugin
var ComponentPlugin = require("component-webpack-plugin");
module.exports = {
plugins: [
new ComponentPlugin()
]
}