-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
61 lines (58 loc) · 1.62 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
import { defineConfig } from 'vite';
import path from 'path';
import { resolve } from 'path';
import react from '@vitejs/plugin-react';
import liveReload from 'vite-plugin-live-reload';
import wasm from 'vite-plugin-wasm';
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill';
import polyfills from 'rollup-plugin-polyfill-node';
import inject from '@rollup/plugin-inject';
const root = resolve(__dirname, './src');
const assetsDir = resolve(root, './assets');
const pagesDir = resolve(root, './pages');
const componentsDir = resolve(root, './components');
const stateDir = resolve(root, './state');
const hooksDir = resolve(root, './hooks');
export default defineConfig({
define: {
global: 'globalThis',
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@assets': assetsDir,
'@pages': pagesDir,
'@components': componentsDir,
'@state': stateDir,
'@hooks': hooksDir,
},
},
plugins: [react(), liveReload('.path'), wasm()],
optimizeDeps: {
esbuildOptions: {
target: 'esnext',
define: {
global: 'globalThis',
},
plugins: [
NodeGlobalsPolyfillPlugin({
process: true,
buffer: true,
}),
NodeModulesPolyfillPlugin(),
],
},
},
build: {
target: 'esnext',
rollupOptions: {
plugins: [polyfills(), inject({ Buffer: ['buffer', 'Buffer'] })],
onLog(warning) {
if (warning?.code === 'MODULE_LEVEL_DIRECTIVE') {
return;
}
},
},
},
});