创建插件MyPlugin.js,内容如下:
class MyPlugin {
apply(compiler) {
console.log('MyPlugin 启动')
}
}
module.exports = MyPlugin配置文件webpack.config.js如下:
module.exports = {
mode: 'production',
entry: './src/index.js',
output: {
clean: true
},
plugins: [new MyPlugin()]
}