06 - 使用插件 - Webpack 官方文档翻译 Get Started

使用插件可以扩展 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()
    ]
}

参照

插件列表

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容