-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.mts
67 lines (61 loc) · 1.59 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
/// <reference types="vitest" />
/// <reference types="vite/client" />
import react from '@vitejs/plugin-react';
import { resolve } from 'path';
import { UserConfig, defineConfig, loadEnv } from 'vite';
import eslint from 'vite-plugin-eslint';
import nodePolyfills from 'vite-plugin-node-stdlib-browser';
// https://vitejs.dev/config/
export default defineConfig(async ({ command, mode }): Promise<UserConfig> => {
const env = loadEnv(mode, process.cwd(), '');
const baseConfig: UserConfig = {
optimizeDeps: {
exclude: ['vite']
},
define: {
global: 'globalThis',
'process.env': {
REACT_APP_SECURE_LOCAL_STORAGE_HASH_KEY: env.REACT_APP_SECURE_LOCAL_STORAGE_HASH_KEY,
},
},
plugins: [react(), nodePolyfills()],
resolve: {
alias: {
'~': resolve(__dirname, 'src'),
Buffer: 'buffer',
},
},
test: {
setupFiles: ['./src/test/vitest.setup.ts'],
environment: 'jsdom',
server: {
deps: {
inline: ['vitest-canvas-mock'],
},
},
globals: true,
css: true,
environmentOptions: {
jsdom: {
resources: 'usable',
},
},
alias: {
'~': resolve(__dirname, 'src'),
Buffer: 'buffer',
},
},
build: {
sourcemap: env.VITE_ENV === 'dev',
},
};
if (command === 'serve') {
baseConfig.plugins = [react(), eslint(), nodePolyfills()];
return baseConfig;
} else if (command === 'build') {
baseConfig.plugins = [react(), nodePolyfills()];
return baseConfig;
} else {
return baseConfig;
}
});