Skip to content

Commit f82f544

Browse files
ndbroadbentclaude
andcommitted
fix: add Vite plugin to load .template files as text for Vitest
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0403588 commit f82f544

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/cache/pipeline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { createHash } from 'node:crypto'
2424
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
2525
import { basename, join } from 'node:path'
2626

27-
export type PipelineStage =
27+
type PipelineStage =
2828
| 'chat'
2929
| 'messages'
3030
| 'parse_stats'

vitest.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1+
import { readFileSync } from 'node:fs'
12
import { loadEnv } from 'vite'
23
import { defineConfig } from 'vitest/config'
34

45
export default defineConfig(({ mode }) => ({
56
esbuild: {
67
tsconfigRaw: '{}'
78
},
9+
plugins: [
10+
{
11+
name: 'template-loader',
12+
transform(_code, id) {
13+
if (id.endsWith('.template')) {
14+
const content = readFileSync(id, 'utf-8')
15+
return `export default ${JSON.stringify(content)}`
16+
}
17+
}
18+
}
19+
],
820
test: {
921
env: loadEnv(mode, process.cwd(), ''),
1022
globals: true,

0 commit comments

Comments
 (0)