mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-07 09:22:27 +00:00
refactor: remove unnecessary onEmit in old webpack
This commit is contained in:
parent
2c763df176
commit
eac6d022f5
@ -6,7 +6,7 @@
|
||||
import hash from 'hash-sum'
|
||||
import uniq from 'lodash/uniq'
|
||||
|
||||
import { isJS, isCSS, onEmit } from './util'
|
||||
import { isJS, isCSS } from './util'
|
||||
|
||||
export default class VueSSRClientPlugin {
|
||||
constructor(options = {}) {
|
||||
@ -16,7 +16,7 @@ export default class VueSSRClientPlugin {
|
||||
}
|
||||
|
||||
apply(compiler) {
|
||||
onEmit(compiler, 'vue-client-plugin', (compilation, cb) => {
|
||||
compiler.hooks.emit.tapAsync('vue-client-plugin', (compilation, cb) => {
|
||||
const stats = compilation.getStats().toJson()
|
||||
|
||||
const allFiles = uniq(stats.assets
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { validate, isJS, onEmit } from './util'
|
||||
import { validate, isJS } from './util'
|
||||
|
||||
export default class VueSSRServerPlugin {
|
||||
constructor(options = {}) {
|
||||
@ -10,7 +10,7 @@ export default class VueSSRServerPlugin {
|
||||
apply(compiler) {
|
||||
validate(compiler)
|
||||
|
||||
onEmit(compiler, 'vue-server-plugin', (compilation, cb) => {
|
||||
compiler.hooks.emit.tapAsync('vue-server-plugin', (compilation, cb) => {
|
||||
const stats = compilation.getStats().toJson()
|
||||
const [entryName] = Object.keys(stats.entrypoints)
|
||||
const entryInfo = stats.entrypoints[entryName]
|
||||
|
@ -22,16 +22,6 @@ export const validate = (compiler) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const onEmit = (compiler, name, hook) => {
|
||||
if (compiler.hooks) {
|
||||
// Webpack >= 4.0.0
|
||||
compiler.hooks.emit.tapAsync(name, hook)
|
||||
} else {
|
||||
// Webpack < 4.0.0
|
||||
compiler.plugin('emit', hook)
|
||||
}
|
||||
}
|
||||
|
||||
export const isJS = file => /\.js(\?[^.]+)?$/.test(file)
|
||||
|
||||
export const isCSS = file => /\.css(\?[^.]+)?$/.test(file)
|
||||
|
Loading…
Reference in New Issue
Block a user