From adcdaee8a2e106256027901538300410870ce6a5 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Wed, 25 Sep 2024 17:35:55 +0900 Subject: [PATCH] fix(browser): serve ui assets as static (#6564) --- packages/browser/src/node/plugin.ts | 8 +++++++- test/browser/vitest.config.mts | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/browser/src/node/plugin.ts b/packages/browser/src/node/plugin.ts index fafa27c51a69..b5fcb2e6ce6b 100644 --- a/packages/browser/src/node/plugin.ts +++ b/packages/browser/src/node/plugin.ts @@ -295,8 +295,14 @@ export default (browserServer: BrowserServer, base = '/'): Plugin[] => { }, { name: 'vitest:browser:assets', + configureServer(server) { + server.middlewares.use( + '/__vitest__', + sirv(resolve(distRoot, 'client/__vitest__')), + ) + }, resolveId(id) { - if (id.startsWith('/__vitest_browser__/') || id.startsWith('/__vitest__/')) { + if (id.startsWith('/__vitest_browser__/')) { return resolve(distRoot, 'client', id.slice(1)) } }, diff --git a/test/browser/vitest.config.mts b/test/browser/vitest.config.mts index d51f62255d0c..fd71c6599a3c 100644 --- a/test/browser/vitest.config.mts +++ b/test/browser/vitest.config.mts @@ -94,4 +94,14 @@ export default defineConfig({ BROWSER: browser, }, }, + plugins: [ + { + name: 'test-no-transform-ui', + transform(_code, id, _options) { + if (id.includes('/__vitest__/')) { + throw new Error(`Unexpected transform: ${id}`) + } + }, + }, + ], })