Skip to content

Commit

Permalink
fix(nuxt): normalize manifest css file entries (nuxt#6112)
Browse files Browse the repository at this point in the history
Thomas authored Jul 25, 2022
1 parent 40defd9 commit 210cf30
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/nuxt/src/core/runtime/nitro/renderer.ts
Original file line number Diff line number Diff line change
@@ -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>`
6 changes: 6 additions & 0 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {

0 comments on commit 210cf30

Please sign in to comment.