Skip to content

Commit

Permalink
fix(browser): serve ui assets as static (#6564)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa authored Sep 25, 2024
1 parent a6407af commit adcdaee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/browser/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
},
Expand Down
10 changes: 10 additions & 0 deletions test/browser/vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
},
},
],
})

0 comments on commit adcdaee

Please sign in to comment.