-
Notifications
You must be signed in to change notification settings - Fork 6
/
vite.config.ts
41 lines (38 loc) · 1.08 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
40
41
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
import { imagetools } from 'vite-imagetools';
import { enhancedImages } from '@sveltejs/enhanced-img';
import { searchForWorkspaceRoot, type Plugin } from 'vite';
const projectRoot = (id: string = 'project-root'): Plugin => {
const virtualModuleId = `virtual:${id}`;
const resolvedVirtualModuleId = '\0' + virtualModuleId;
return {
name: 'project-root',
resolveId(id) {
if (id === virtualModuleId) {
return resolvedVirtualModuleId;
}
},
load(id) {
if (id === resolvedVirtualModuleId) {
const projectRoot = JSON.stringify(searchForWorkspaceRoot(process.cwd()));
return `export default ${projectRoot};`;
}
},
};
};
export default defineConfig({
plugins: [sveltekit(), enhancedImages(), imagetools(), projectRoot()],
esbuild: {
jsxFactory: 'h',
jsxFragment: 'Fragment',
},
test: {
include: ['src/**/*.{test,spec}.{js,ts}', 'compilers/**/*.{test,spec}.{js,ts}'],
},
server: {
fs: {
allow: [searchForWorkspaceRoot(process.cwd()), '/content/**'],
},
},
});