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 hash from 'hash-sum'
import uniq from 'lodash/uniq' import uniq from 'lodash/uniq'
import { Compilation } from 'webpack'
import { isJS, isCSS } from './util' import { isJS, isCSS } from './util'
export default class VueSSRClientPlugin { export default class VueSSRClientPlugin {
options: {
filename: string
}
constructor (options = {}) { constructor (options = {}) {
this.options = Object.assign({ this.options = Object.assign({
filename: null filename: null
@ -16,7 +21,11 @@ export default class VueSSRClientPlugin {
} }
apply (compiler) { 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 stats = compilation.getStats().toJson()
const allFiles = uniq(stats.assets const allFiles = uniq(stats.assets
@ -101,11 +110,12 @@ export default class VueSSRClientPlugin {
const src = JSON.stringify(manifest, null, 2) const src = JSON.stringify(manifest, null, 2)
compilation.assets[this.options.filename] = { assets[this.options.filename] = {
source: () => src, source: () => src,
size: () => src.length size: () => src.length
} }
cb() cb()
}) })
})
} }
} }