mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +00:00
fix(webpack): remove hmr chunks from client manifest
This commit is contained in:
parent
7b3244a567
commit
64ca193ac9
@ -8,7 +8,7 @@ import hash from 'hash-sum'
|
|||||||
import uniq from 'lodash/uniq'
|
import uniq from 'lodash/uniq'
|
||||||
import { writeFile, mkdirp } from 'fs-extra'
|
import { writeFile, mkdirp } from 'fs-extra'
|
||||||
|
|
||||||
import { isJS, isCSS } from './util'
|
import { isJS, isCSS, isHotUpdate } from './util'
|
||||||
|
|
||||||
export default class VueSSRClientPlugin {
|
export default class VueSSRClientPlugin {
|
||||||
options: {
|
options: {
|
||||||
@ -27,19 +27,23 @@ export default class VueSSRClientPlugin {
|
|||||||
|
|
||||||
const allFiles = uniq(stats.assets
|
const allFiles = uniq(stats.assets
|
||||||
.map(a => a.name))
|
.map(a => a.name))
|
||||||
|
.filter(file => !isHotUpdate(file))
|
||||||
|
|
||||||
const initialFiles = uniq(Object.keys(stats.entrypoints)
|
const initialFiles = uniq(Object.keys(stats.entrypoints)
|
||||||
.map(name => stats.entrypoints[name].assets)
|
.map(name => stats.entrypoints[name].assets)
|
||||||
.reduce((files, entryAssets) => files.concat(entryAssets.map(entryAsset => entryAsset.name)), [])
|
.reduce((files, entryAssets) => files.concat(entryAssets.map(entryAsset => entryAsset.name)), [])
|
||||||
.filter(file => isJS(file) || isCSS(file)))
|
.filter(file => isJS(file) || isCSS(file)))
|
||||||
|
.filter(file => !isHotUpdate(file))
|
||||||
|
|
||||||
const asyncFiles = allFiles
|
const asyncFiles = allFiles
|
||||||
.filter(file => isJS(file) || isCSS(file))
|
.filter(file => isJS(file) || isCSS(file))
|
||||||
.filter(file => !initialFiles.includes(file))
|
.filter(file => !initialFiles.includes(file))
|
||||||
|
.filter(file => !isHotUpdate(file))
|
||||||
|
|
||||||
const assetsMapping = {}
|
const assetsMapping = {}
|
||||||
stats.assets
|
stats.assets
|
||||||
.filter(({ name }) => isJS(name))
|
.filter(({ name }) => isJS(name))
|
||||||
|
.filter(({ name }) => !isHotUpdate(name))
|
||||||
.forEach(({ name, chunkNames }) => {
|
.forEach(({ name, chunkNames }) => {
|
||||||
const componentHash = hash(chunkNames.join('|'))
|
const componentHash = hash(chunkNames.join('|'))
|
||||||
if (!assetsMapping[componentHash]) {
|
if (!assetsMapping[componentHash]) {
|
||||||
@ -69,7 +73,7 @@ export default class VueSSRClientPlugin {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const id = m.identifier.replace(/\s\w+$/, '') // remove appended hash
|
const id = m.identifier.replace(/\s\w+$/, '') // remove appended hash
|
||||||
const filesSet = new Set(chunk.files.map(fileToIndex))
|
const filesSet = new Set(chunk.files.map(fileToIndex).filter(i => i !== -1))
|
||||||
|
|
||||||
for (const chunkName of chunk.names) {
|
for (const chunkName of chunk.names) {
|
||||||
if (!entrypoints[chunkName]) {
|
if (!entrypoints[chunkName]) {
|
||||||
|
@ -30,3 +30,5 @@ export const isJS = file => isJSRegExp.test(file)
|
|||||||
export const extractQueryPartJS = file => isJSRegExp.exec(file)[1]
|
export const extractQueryPartJS = file => isJSRegExp.exec(file)[1]
|
||||||
|
|
||||||
export const isCSS = file => /\.css(\?[^.]+)?$/.test(file)
|
export const isCSS = file => /\.css(\?[^.]+)?$/.test(file)
|
||||||
|
|
||||||
|
export const isHotUpdate = file => file.includes('hot-update')
|
||||||
|
Loading…
Reference in New Issue
Block a user