mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(nuxt): inline global css with ssr: false
route rule (#21763)
This commit is contained in:
parent
5b8370414a
commit
4cc9a7135d
@ -126,6 +126,7 @@ const getSPARenderer = lazyCachedFunction(async () => {
|
||||
|
||||
const renderToString = (ssrContext: NuxtSSRContext) => {
|
||||
const config = useRuntimeConfig()
|
||||
ssrContext.modules = ssrContext.modules || new Set<string>()
|
||||
ssrContext!.payload = {
|
||||
_errors: {},
|
||||
serverRendered: false,
|
||||
|
@ -1169,6 +1169,17 @@ describe.skipIf(isDev() || isWebpack)('inlining component styles', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('should inline global css when accessing a page with `ssr: false` override via route rules', async () => {
|
||||
const globalCSS = [
|
||||
'{--plugin:"plugin"}', // CSS imported ambiently in JS/TS
|
||||
'{--global:"global";' // global css from nuxt.config
|
||||
]
|
||||
const html = await $fetch('/route-rules/spa')
|
||||
for (const style of globalCSS) {
|
||||
expect(html).toContain(style)
|
||||
}
|
||||
})
|
||||
|
||||
it('should not include inlined CSS in generated CSS file', async () => {
|
||||
const html: string = await $fetch('/styles')
|
||||
const cssFiles = new Set([...html.matchAll(/<link [^>]*href="([^"]*\.css)">/g)].map(m => m[1]))
|
||||
|
@ -35,7 +35,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
|
||||
|
||||
it('default server bundle size', async () => {
|
||||
stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
||||
expect.soft(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"63.9k"')
|
||||
expect.soft(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"64.0k"')
|
||||
|
||||
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
||||
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2328k"')
|
||||
|
Loading…
Reference in New Issue
Block a user