使用插件可以擴(kuò)展 Webpack 的功能,比如 BellOnBundlerErrorPlugin 會在你構(gòu)建過程出現(xiàn)錯誤時發(fā)出通知
內(nèi)置插件
內(nèi)置插件可以直接配置實(shí)用
// 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()
]
}