forked from decentraland/marketplace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
72 lines (71 loc) · 2.36 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
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
import react from '@vitejs/plugin-react-swc'
import rollupNodePolyFill from 'rollup-plugin-polyfill-node'
import { defineConfig, UserConfig, loadEnv, splitVendorChunkPlugin } from 'vite'
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const envVariables = loadEnv(mode, process.cwd())
return {
plugins: [react(), splitVendorChunkPlugin()],
// Required because the CatalystClient tries to access it
define: {
// eslint-disable-next-line @typescript-eslint/naming-convention
'process.env': {
// eslint-disable-next-line @typescript-eslint/naming-convention
VITE_DCL_DEFAULT_ENV: envVariables.VITE_DCL_DEFAULT_ENV,
VITE_BASE_URL: envVariables.VITE_BASE_URL
},
global: {}
},
resolve: {
alias: {
// This Rollup aliases are extracted from @esbuild-plugins/node-modules-polyfill,
// see https://github.com/remorses/esbuild-plugins/blob/master/node-modules-polyfill/src/polyfills.ts
// process and buffer are excluded because already managed
// by node-globals-polyfill
util: 'rollup-plugin-node-polyfills/polyfills/util',
assert: 'rollup-plugin-node-polyfills/polyfills/assert'
}
},
server: {
open: true,
proxy: {
// eslint-disable-next-line @typescript-eslint/naming-convention
'/auth': {
target: 'https://decentraland.zone',
followRedirects: true,
changeOrigin: true,
secure: false,
ws: true
}
}
},
optimizeDeps: {
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: 'globalThis'
},
// Enable esbuild polyfill plugins
plugins: [
NodeGlobalsPolyfillPlugin({
buffer: false,
process: false
}),
NodeModulesPolyfillPlugin()
]
}
},
build: {
commonjsOptions: {
transformMixedEsModules: true
},
rollupOptions: {
plugins: [rollupNodePolyFill()]
},
sourcemap: true
},
...(command === 'build' ? { base: envVariables.VITE_BASE_URL } : undefined)
} as unknown as UserConfig
})