-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
53 lines (49 loc) · 1.3 KB
/
vite.config.js
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
import { defineConfig, loadEnv } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import postcss from './postcss.config.js'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
return defineConfig({
define: {
'process.env': process.env
},
css: {
postcss,
},
plugins: [
nodePolyfills({
// To exclude specific polyfills, add them to this list. Note: if include is provided, this has no effect
exclude: [],
// Whether to polyfill specific globals.
globals: {
Buffer: true, // can also be 'build', 'dev', or false
global: true,
process: true,
},
overrides: {
// Since `fs` is not supported in browsers, we can use the `memfs` package to polyfill it.
},
// Whether to polyfill `node:` protocol imports.
protocolImports: true,
}),
react(),
],
resolve: {
alias: [
{
find: /^~.+/,
replacement: (val) => {
return val.replace(/^~/, "");
},
},
],
},
build: {
commonjsOptions: {
transformMixedEsModules: true,
}
}
})
}