mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(webpack): DeprecationWarning DEP_WEBPACK_COMPILATION_ASSETS (#57)
This commit is contained in:
parent
5a7f5164f0
commit
20c2375e74
@ -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()
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user