Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

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

Merged
merged 5 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/nuxt/src/core/runtime/nitro/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:/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({
Expand All @@ -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>`
Expand Down
6 changes: 6 additions & 0 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down