forked from vaadin/hilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
44 lines (40 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
42
43
44
import { readFile } from 'node:fs/promises';
import { resolve } from 'node:path';
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from 'vite';
// The current package, one of the packages in the `packages` dir
const cwd = process.cwd();
async function prepareAliases() {
try {
const contents = await readFile(resolve(cwd, 'test/mocks.json'), 'utf8');
return Object.fromEntries(
Object.entries(JSON.parse(contents) as Record<string, string>).map(([key, value]) => [key, resolve(cwd, value)]),
);
} catch {
return {};
}
}
// https://vitejs.dev/config/
export default defineConfig(async () => {
const [tsconfig, alias] = await Promise.all([
readFile(resolve(cwd, 'tsconfig.json'), 'utf8').then((f) => JSON.parse(f)),
prepareAliases(),
]);
return {
build: {
target: 'esnext',
},
esbuild: {
tsconfigRaw: {
...tsconfig,
compilerOptions: {
...tsconfig.compilerOptions,
useDefineForClassFields: false,
},
},
},
resolve: {
alias,
},
};
});