mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-20 16:25:55 +00:00
test: normalise scoped css + pass logger to configResolved
This commit is contained in:
parent
24e2c327b4
commit
8d3bd4f9fa
@ -3,6 +3,7 @@ import path from 'node:path'
|
|||||||
import { describe, expect, it, vi } from 'vitest'
|
import { describe, expect, it, vi } from 'vitest'
|
||||||
import * as VueCompilerSFC from 'vue/compiler-sfc'
|
import * as VueCompilerSFC from 'vue/compiler-sfc'
|
||||||
import type { Plugin } from 'vite'
|
import type { Plugin } from 'vite'
|
||||||
|
import { createLogger } from 'vite'
|
||||||
import type { Options } from '@vitejs/plugin-vue'
|
import type { Options } from '@vitejs/plugin-vue'
|
||||||
import _vuePlugin from '@vitejs/plugin-vue'
|
import _vuePlugin from '@vitejs/plugin-vue'
|
||||||
import { TreeShakeTemplatePlugin } from '../src/components/plugins/tree-shake'
|
import { TreeShakeTemplatePlugin } from '../src/components/plugins/tree-shake'
|
||||||
@ -66,6 +67,7 @@ async function SFCCompile (name: string, source: string, options: Options, ssr =
|
|||||||
})
|
})
|
||||||
// @ts-expect-error Types are not correct as they are too generic
|
// @ts-expect-error Types are not correct as they are too generic
|
||||||
plugin.configResolved!({
|
plugin.configResolved!({
|
||||||
|
logger: createLogger(),
|
||||||
isProduction: options.isProduction,
|
isProduction: options.isProduction,
|
||||||
command: 'build',
|
command: 'build',
|
||||||
root: process.cwd(),
|
root: process.cwd(),
|
||||||
|
@ -2435,13 +2435,16 @@ describe('component islands', () => {
|
|||||||
// TODO: resolve dev bug triggered by earlier fetch of /vueuse-head page
|
// TODO: resolve dev bug triggered by earlier fetch of /vueuse-head page
|
||||||
// https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/core/runtime/nitro/handlers/renderer.ts#L139
|
// https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/core/runtime/nitro/handlers/renderer.ts#L139
|
||||||
result.head.link = result.head.link?.filter(l => typeof l.href !== 'string' || !l.href.includes('SharedComponent'))
|
result.head.link = result.head.link?.filter(l => typeof l.href !== 'string' || !l.href.includes('SharedComponent'))
|
||||||
|
if (result.head.link?.[0]?.href) {
|
||||||
|
result.head.link[0].href = result.head.link[0].href.replace(/scoped=[^?&]+/, 'scoped=xxxxx')
|
||||||
|
}
|
||||||
|
|
||||||
expect(result.head).toMatchInlineSnapshot(`
|
expect(result.head).toMatchInlineSnapshot(`
|
||||||
{
|
{
|
||||||
"link": [
|
"link": [
|
||||||
{
|
{
|
||||||
"crossorigin": "",
|
"crossorigin": "",
|
||||||
"href": "/_nuxt/components/islands/PureComponent.vue?vue&type=style&index=0&scoped=c0c0cf89&lang.css",
|
"href": "/_nuxt/components/islands/PureComponent.vue?vue&type=style&index=0&scoped=xxxxx&lang.css",
|
||||||
"rel": "stylesheet",
|
"rel": "stylesheet",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user