【文件属性】:
文件名称:webpack-plugin
文件大小:20KB
文件格式:ZIP
更新时间:2021-05-29 05:26:32
JavaScript
webpack-plugin
插件的基本结构
class MyPlugin {
apply(compiler) {
compiler.hooks.done.tap('My Plugin', (stats) => {
console.log('Hello World!');
});
}
}
module.exports = MyPlugin;
插件的使用
plugins: [new MyPlugin()]
插件参数获取
module.exports = class MyPlugin {
constructor(options) {
this.options = options;
}
apply() {
console.log('apply', this.options);
}
};
插件的错误处理
参数校验阶段可以直接 th
【文件预览】:
webpack-plugin-master
----.gitignore(2KB)
----package.json(331B)
----src()
--------index.js(0B)
----webpack.config.js(289B)
----LICENSE(1KB)
----README.md(824B)
----plugins()
--------test-plugin.js(217B)
----yarn.lock(39KB)