-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvite.config.ts
78 lines (74 loc) · 1.93 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
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
71
72
73
74
75
76
77
78
/// <reference types="vitest" />
import react from '@vitejs/plugin-react'
import { defineConfig, loadEnv } from 'vite'
import dotenv from 'dotenv'
import tsconfigPaths from 'vite-tsconfig-paths'
import { resolve } from 'path'
import dynamicImport from 'vite-plugin-dynamic-import'
import Config from './config.json'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
dotenv.config()
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }
// import.meta.env.VITE_PORT available here with: process.env.VITE_PORT
return defineConfig({
base: '/',
plugins: [
react({
jsxImportSource: '@emotion/react',
jsxRuntime: 'automatic',
babel: {
plugins: ['@emotion/babel-plugin'],
},
}),
tsconfigPaths({ root: '.' }),
dynamicImport({}),
// nodePolyfills(),
],
server: {
host: Config.DOMAIN,
port: Number(Config.FRONTEND_PORT) || 5143,
strictPort: true,
// hmr: {
// protocol: 'wss',
// clientPort: 9443,
// },
https: {
key: '../certificates/localhost-key.pem',
cert: '../certificates/localhost.pem',
},
},
optimizeDeps: {
exclude: ['react-hook-form'],
},
define: {
'process.env.NODE_ENV': `"${mode}"`,
},
esbuild: {
logOverride: { 'this-is-undefined-in-esm': 'silent' },
},
build: {
minify: 'terser',
commonjsOptions: {
transformMixedEsModules: true,
},
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
outDir: './build',
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
// nested: resolve(__dirname, 'nested/index.html')
},
external: ['src/index.tsx'],
},
dynamicImportVarsOptions: {
exclude: [],
},
},
})
}