-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathvite.config.ts
More file actions
138 lines (137 loc) · 3.44 KB
/
vite.config.ts
File metadata and controls
138 lines (137 loc) · 3.44 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { defineConfig } from 'vite'
// port over to plugin-react-swc once we no longer need babel
import react from '@vitejs/plugin-react'
import eslint from 'vite-plugin-eslint'
import macrosPlugin from 'vite-plugin-babel-macros'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import wasm from 'vite-plugin-wasm'
import topLevelAwait from 'vite-plugin-top-level-await'
import requireTransform from 'vite-plugin-require-transform'
import viteCompression from 'vite-plugin-compression'
import { ViteImageOptimizer } from 'vite-plugin-image-optimizer'
import tsconfigPaths from 'vite-tsconfig-paths'
import { getThemeVariables } from 'antd/dist/theme'
import svgr from 'vite-plugin-svgr'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
plugins: [
nodePolyfills(),
tsconfigPaths(),
wasm(),
topLevelAwait(),
svgr(),
react({
include: /.(jsx|tsx)$/,
babel: {
plugins: ['babel-plugin-macros', 'styled-components']
}
}),
eslint(),
macrosPlugin(),
requireTransform({}),
ViteImageOptimizer({
svg: {
multipass: true,
plugins: [
{
name: 'preset-default',
params: {
overrides: {
cleanupNumericValues: false,
removeViewBox: false // https://github.com/svg/svgo/issues/1128
},
cleanupIDs: {
minify: false,
remove: false
},
convertPathData: false
}
},
'sortAttrs',
{
name: 'addAttributesToSVGElement',
params: {
attributes: [{ xmlns: 'http://www.w3.org/2000/svg' }]
}
}
]
},
png: {
// https://sharp.pixelplumbing.com/api-output#png
quality: 90
},
jpeg: {
// https://sharp.pixelplumbing.com/api-output#jpeg
quality: 80
},
jpg: {
// https://sharp.pixelplumbing.com/api-output#jpeg
quality: 80
},
tiff: {
// https://sharp.pixelplumbing.com/api-output#tiff
quality: 80
}
}),
viteCompression()
],
css: {
preprocessorOptions: {
less: {
math: 'always',
relativeUrls: true,
modifyVars: getThemeVariables({
dark: true
// compact: true,
}),
javascriptEnabled: true
}
}
},
server: {
port: 3000
},
preview: {
port: 3000
},
esbuild: {
drop: mode == 'development' ? [] : ['console', 'debugger'],
pure: mode === 'production' ? ['console.log'] : []
},
build: {
outDir: 'build',
target: ['es2022', 'chrome89', 'firefox89', 'safari15.4', 'edge89'],
commonjsOptions: {
transformMixedEsModules: true
},
minify: 'esbuild',
cssMinify: 'esbuild',
sourcemap: false,
output: {
cache: false,
sourcemap: false,
maxParallelFileOps: 1
}
},
resolve: {
alias: [
{ find: /^~/, replacement: '' },
{ find: /^@\//, replacement: '/src/' },
{ find: 'goosefx-amm-sdk', replacement: '/gamma-sdk' },
{ find: 'process/', replacement: 'process' },
]
},
assetsInclude: ['gamma-wasm/gamma_wasm_bg.wasm'],
optimizeDeps: {
exclude: ['process', 'process/'],
esbuildOptions: {
define: {
global: 'globalThis'
}
}
},
define: {
// Only keep valid define keys
'process.env': '{}'
}
}))