-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.mts
70 lines (65 loc) · 1.62 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/// <reference types="vitest" />
/// <reference types="vite-plugin-svgr/client" />
import {defineConfig, transformWithEsbuild} from 'vite'
import react from '@vitejs/plugin-react';
import viteTsconfigPaths from 'vite-tsconfig-paths';
import svgrPlugin from 'vite-plugin-svgr';
// https://vitejs.dev/config/
export default defineConfig({
base: '/',
server: {
port: process.env.PORT ? Number(process.env.PORT) : 9000,
},
publicDir: 'public',
build: {
outDir: 'build',
sourcemap: true,
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes("node_modules")) {
return 'vendor';
} else if (!id.includes("/static/lang/")) {
return 'index';
}
}
}
}
},
plugins: [
react(), viteTsconfigPaths(), svgrPlugin(),
{
name: 'treat-js-files-as-jsx',
async transform(code, id) {
if (!id.match(/src\/.*\.js$/)) return null
// Use the exposed transform from vite, instead of directly
// transforming with esbuild
return transformWithEsbuild(code, id, {
loader: 'jsx',
jsx: 'automatic',
})
},
},
],
optimizeDeps: {
force: true,
esbuildOptions: {
loader: {
'.js': 'jsx',
},
},
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: './src/setupTests.ts',
css: true,
reporters: ['verbose'],
coverage: {
reporter: ['text', 'json', 'html'],
include: ['src/**/*'],
exclude: [],
}
},
define: process.env.NODE_ENV === 'development' ? { global: 'window' } : {},
});