fix(webpack): DeprecationWarning DEP_WEBPACK_COMPILATION_ASSETS (#57)

This commit is contained in:
Xin Du (Clark) 2020-09-30 13:03:13 +01:00 committed by GitHub
parent 5a7f5164f0
commit 20c2375e74

View File

@ -5,10 +5,15 @@
import hash from 'hash-sum'
import uniq from 'lodash/uniq'
import { Compilation } from 'webpack'
import { isJS, isCSS } from './util'
export default class VueSSRClientPlugin {
options: {
filename: string
}
constructor (options = {}) {
this.options = Object.assign({
filename: null
@ -16,7 +21,11 @@ export default class VueSSRClientPlugin {
}
apply (compiler) {
compiler.hooks.emit.tapAsync('vue-client-plugin', (compilation, cb) => {
compiler.hooks.make.tap('VueSSRClientPlugin', (compilation: any) => {
compilation.hooks.processAssets.tapAsync({
name: 'VueSSRClientPlugin',
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
}, (assets, cb) => {
const stats = compilation.getStats().toJson()
const allFiles = uniq(stats.assets
@ -101,11 +110,12 @@ export default class VueSSRClientPlugin {
const src = JSON.stringify(manifest, null, 2)
compilation.assets[this.options.filename] = {
assets[this.options.filename] = {
source: () => src,
size: () => src.length
}
cb()
})
})
}
}