-
Notifications
You must be signed in to change notification settings - Fork 6
/
vite.config.mts
50 lines (45 loc) · 1.08 KB
/
vite.config.mts
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
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vitest/config';
const plugins = [react()];
const pages = fs.readdirSync(new URL('pages', import.meta.url));
const rollupInputOptions = {
index: fileURLToPath(new URL('index.html', import.meta.url)),
...Object.fromEntries(
pages.map((page) => [
page,
fileURLToPath(new URL(`pages/${page}`, import.meta.url)),
]),
),
};
// https://vitejs.dev/config/
export default defineConfig({
base: process.env.VITE_BASE || '/',
esbuild: {
jsx: 'automatic',
},
optimizeDeps: {
esbuildOptions: {
target: 'esnext',
},
},
build: {
target: 'esnext',
rollupOptions: {
input: rollupInputOptions,
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
return 'vendor';
}
},
},
},
minify: process.env.NO_MINIFY ? false : 'esbuild',
},
plugins,
test: {
include: ['./src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
},
});