-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
39 lines (36 loc) · 1.4 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vitest/config";
import { execSync } from "child_process";
export default defineConfig({
plugins: [
sveltekit(),
{
name: "Parser auto-generation",
async handleHotUpdate(ctx) {
if (ctx.file.endsWith(".g4")) {
const grammarRoot = ctx.file.slice(0, ctx.file.lastIndexOf("/"));
const getModule = (filename: string) => {
return ctx.server.moduleGraph.getModuleById(`${grammarRoot}/.antlr/${filename}`)!;
};
// Wait untill all files are generated and then trigger HMR for all of them at once
execSync("npm run generate");
return [
getModule("DSLLexer.ts"),
getModule("DSLParser.ts"),
getModule("DSLVisitor.ts"),
];
}
}
}
],
server: {
watch: {
// Don't watch auto-generated files - instead, trigger HMR for them manually, as a single update
// Otherwise each generated fille would trigger the update resulting in excessive module reloads
ignored: ["**/.antlr/*"]
}
},
test: {
include: ["tests/{unit,integration}/**/*.{test,spec}.{js,ts}"]
}
});