diff --git a/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts b/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts index b92da5fc22bd63..f0ab340bc0ae4b 100644 --- a/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts +++ b/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts @@ -142,3 +142,8 @@ test('client navigation', async () => { editFile('src/pages/About.vue', (code) => code.replace('About', 'changed')) await untilUpdated(() => page.textContent('h1'), 'changed') }) + +test('import.meta.url', async () => { + await page.goto(url) + expect(await page.textContent('.protocol')).toEqual('file:') +}) \ No newline at end of file diff --git a/packages/playground/ssr-vue/src/pages/Home.vue b/packages/playground/ssr-vue/src/pages/Home.vue index b0003df3e9d0c9..05d39cf69ff1ae 100644 --- a/packages/playground/ssr-vue/src/pages/Home.vue +++ b/packages/playground/ssr-vue/src/pages/Home.vue @@ -7,6 +7,8 @@

msg from virtual module: {{ foo.msg }}

this will be styled with a font-face

+

{{ state.url }}

+

{{ state.protocol }}

@@ -21,7 +23,13 @@ const Foo = defineAsyncComponent(() => function load(file) { return defineAsyncComponent(() => import(`../components/${file}.vue`)) } -const state = reactive({ count: 0 }) +const url = import.meta.env.SSR ? import.meta.url : document.querySelector('.import-meta-url').textContent +const protocol = new URL(url).protocol +const state = reactive({ + count: 0, + protocol, + url +})