mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
feat(ssr): render initial and used async css chunks (vuejs/vue#7902)
This commit is contained in:
parent
dfab96fdb7
commit
2428a13c05
@ -1,6 +1,6 @@
|
|||||||
import hash from 'hash-sum'
|
import hash from 'hash-sum'
|
||||||
import uniq from 'lodash.uniq'
|
import uniq from 'lodash/uniq'
|
||||||
import { isJS, onEmit } from './util'
|
import { isJS, isCSS, onEmit } from './util'
|
||||||
|
|
||||||
export default class VueSSRClientPlugin {
|
export default class VueSSRClientPlugin {
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
@ -19,10 +19,10 @@ export default class VueSSRClientPlugin {
|
|||||||
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((assets, all) => all.concat(assets), [])
|
.reduce((assets, all) => all.concat(assets), [])
|
||||||
.filter(isJS))
|
.filter((file) => isJS(file) || isCSS(file)))
|
||||||
|
|
||||||
const asyncFiles = allFiles
|
const asyncFiles = allFiles
|
||||||
.filter(isJS)
|
.filter((file) => isJS(file) || isCSS(file))
|
||||||
.filter(file => initialFiles.indexOf(file) < 0)
|
.filter(file => initialFiles.indexOf(file) < 0)
|
||||||
|
|
||||||
const manifest = {
|
const manifest = {
|
||||||
@ -43,7 +43,8 @@ export default class VueSSRClientPlugin {
|
|||||||
if (!chunk || !chunk.files) {
|
if (!chunk || !chunk.files) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const files = manifest.modules[hash(m.identifier)] = chunk.files.map(fileToIndex)
|
const id = m.identifier.replace(/\s\w+$/, '') // remove appended hash
|
||||||
|
const files = manifest.modules[hash(id)] = chunk.files.map(fileToIndex)
|
||||||
// find all asset modules associated with the same chunk
|
// find all asset modules associated with the same chunk
|
||||||
assetModules.forEach(m => {
|
assetModules.forEach(m => {
|
||||||
if (m.chunks.some(id => id === cid)) {
|
if (m.chunks.some(id => id === cid)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user