-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.ts
41 lines (39 loc) · 1.1 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
import { defineConfig, Plugin, ConfigEnv } from 'vite';
import react from '@vitejs/plugin-react';
import fs from 'fs';
import path from 'path';
const particleWasmPlugin: Plugin | undefined = {
name: 'particle-wasm',
apply: (_, env: ConfigEnv) => {
return env.mode === 'development';
},
buildStart: () => {
const copiedPath = path.join(
__dirname,
'node_modules/@particle-network/thresh-sig/wasm/thresh_sig_wasm_bg.wasm'
);
const dir = path.join(__dirname, 'node_modules/.vite/wasm');
const resultPath = path.join(dir, 'thresh_sig_wasm_bg.wasm');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
fs.copyFileSync(copiedPath, resultPath);
},
};
export default defineConfig({
plugins: [react(), particleWasmPlugin],
server: {
host: '0.0.0.0',
},
define: {
'process.env': process.env
},
build: {
target: 'esnext', // you can also use 'es2020' here
},
optimizeDeps: {
esbuildOptions: {
target: 'esnext', // you can also use 'es2020' here
},
},
});