Skip to content

Commit cab6087

Browse files
chore: gate cache stub on vitest
Co-authored-by: me <me@kentcdodds.com>
1 parent 1c39be1 commit cab6087

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

vite.config.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ import { iconsSpritesheet } from 'vite-plugin-icons-spritesheet'
1313
export default defineConfig((config) => {
1414
const mode = config.mode ?? process.env.NODE_ENV
1515
const isTest = mode === 'test' || Boolean(process.env.VITEST)
16-
const cacheServerStubPlugin = isTest
17-
? {
18-
name: 'vitest-cache-server-stub',
19-
resolveId(source: string) {
20-
if (source.endsWith('cache.server.ts')) {
21-
return path.resolve('tests/mocks/cache-server.ts')
22-
}
23-
return null
24-
},
16+
const cacheServerStubPlugin = {
17+
name: 'vitest-cache-server-stub',
18+
enforce: 'pre' as const,
19+
resolveId(source: string) {
20+
if (!process.env.VITEST) return null
21+
if (source.endsWith('cache.server.ts')) {
22+
return path.resolve('tests/mocks/cache-server.ts')
2523
}
26-
: null
24+
return null
25+
},
26+
}
2727
return {
2828
build: {
2929
target: 'es2022',

0 commit comments

Comments
 (0)