fix(nuxt): normalize manifest css file entries (#6112)

This commit is contained in:
Thomas 2022-07-25 20:05:58 +08:00 committed by GitHub
parent 40defd9f36
commit 210cf30691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -83,7 +83,10 @@ const getSPARenderer = lazyCachedFunction(async () => {
if ('all' in clientManifest && 'initial' in clientManifest) {
// Upgrade legacy manifest (also see normalizeClientManifest in vue-bundle-renderer)
// https://github.com/nuxt-contrib/vue-bundle-renderer/issues/12
entryFiles = clientManifest.initial.map(file => ({ file }))
entryFiles = clientManifest.initial.map(file =>
// Webpack manifest fix with SPA renderer
file.endsWith('css') ? { css: file } : { file }
)
}
return Promise.resolve({
@ -97,6 +100,7 @@ const getSPARenderer = lazyCachedFunction(async () => {
.join(''),
renderScripts: () =>
entryFiles
.filter(({ file }) => file)
.map(({ file }) => {
const isMJS = !file.endsWith('.js')
return `<script ${isMJS ? 'type="module"' : ''} src="${buildAssetsURL(file)}"></script>`

View File

@ -145,6 +145,12 @@ describe('head tags', () => {
// should render <Head> components
expect(index).toContain('<title>Basic fixture - Fixture</title>')
})
// TODO: Doesn't adds header in test environment
// it.todo('should render stylesheet link tag (SPA mode)', async () => {
// const html = await $fetch('/head', { headers: { 'x-nuxt-no-ssr': '1' } })
// expect(html).toMatch(/<link rel="stylesheet" href="\/_nuxt\/[^>]*.css"/)
// })
})
describe('navigate', () => {