@parabol/webpack-autodll-plugin
Version:
AutoDLL Webpack Plugin for handling DLL caching outside of webpack.
46 lines (38 loc) • 1.29 kB
JavaScript
;const CacheController = require('./CacheController')
const BundleController = require('./BundleController')
class WebpackAutodllPlugin {
constructor(options) {;WebpackAutodllPlugin.prototype.__init.call(this);
this.options = options
this.hasCompile = false
this.cacheController = new CacheController({
lockfile: options.lockfile,
})
this.bundleController = new BundleController({
vendors: options.vendors,
})
}
__init() {this.check = async (compilation, cb) => {
if (!this.hasCompile) {
this.hasCompile = true
if (this.cacheController.shouldUpdateCache()) {
const assets = await this.bundleController.webpackBuild()
console.log('cached assets', assets)
} else {
console.log(`📘 Using cached DLL`)
// resolve()
}
}
return cb()
}}
apply(compiler) {
compiler.hooks.beforeCompile.tapAsync('WebpackAutodllPlugin', this.check)
compiler.hooks.done.tap(
'WebpackAutodllPlugin',
(stats /* stats is passed as an argument when done hook is tapped. */) => {
console.log('🔥🚀 Of Course I Still Love You.')
},
)
this.bundleController.dllReferencePlugin.apply(compiler)
}
}
module.exports = WebpackAutodllPlugin