-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathvite.config.ts
More file actions
66 lines (61 loc) · 2.17 KB
/
vite.config.ts
File metadata and controls
66 lines (61 loc) · 2.17 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { defineConfig, type Plugin } from "vitest/config";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import monacoEditorPluginModule from "vite-plugin-monaco-editor";
import path from "path";
const monacoEditorPlugin = (monacoEditorPluginModule as any).default || monacoEditorPluginModule;
const host = process.env.TAURI_DEV_HOST;
// Only bundle commonly-used Shiki language grammars (saves ~8 MB in build).
// Languages not listed here will gracefully degrade (no syntax highlighting).
const SHIKI_ALLOWED_LANGS = new Set([
"angular-html", "angular-ts", "astro", "bash", "c", "cpp", "csharp",
"css", "dart", "dockerfile", "go", "graphql", "html", "html-derivative",
"java", "javascript", "json", "json5", "jsonc", "jsx", "kotlin", "less",
"lua", "markdown", "mdc", "mdx", "objective-c", "objective-cpp", "php",
"python", "ruby", "rust", "sass", "scss", "shell", "shellscript",
"sql", "svelte", "swift", "toml", "tsx", "typescript", "vue",
"vue-html", "xml", "yaml",
]);
function shikiLanguageFilter(): Plugin {
return {
name: "shiki-language-filter",
enforce: "pre",
resolveId(id) {
const m = id.match(/^@shikijs\/langs\/(.+)$/);
if (m && !SHIKI_ALLOWED_LANGS.has(m[1])) {
return "\0shiki-lang-noop";
}
return null;
},
load(id) {
if (id === "\0shiki-lang-noop") {
return "export default []";
}
return null;
},
};
}
export default defineConfig(async () => ({
plugins: [react(), tailwindcss(), monacoEditorPlugin({}), shikiLanguageFilter()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"stream-monaco": path.resolve(__dirname, "./libs/stream-monaco"),
"stream-markdown-parser": path.resolve(__dirname, "./libs/markstream-vue/packages/markdown-parser"),
},
},
clearScreen: false,
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host ? { protocol: "ws", host, port: 1421 } : undefined,
watch: { ignored: ["**/src-tauri/**"] },
},
test: {
environment: "jsdom",
globals: true,
setupFiles: ["./src/test/setup.ts"],
include: ["src/**/*.{test,spec}.{ts,tsx}"],
},
}));