動手實作 Webpack-Plugin
基本的 Plugin 架構
實現 Hello-World-Plugin
function HelloWorldPlugin(options) {
this.options = options
}
HelloWorldPlugin.prototype.apply = function (compiler) {
compiler.plugin('done', function () {
console.log('Hello World!')
})
compiler.plugin('compilation', function (compilation) {
console.log(compilation.assets)
compilation.plugin('optimize', function () {
console.log('Assets are being optimized.')
})
})
}
Subscribe to TYSON Tech Blog
Get the latest posts delivered right to your inbox