Skip to content

Commit 61b76ef

Browse files
committed
Vercel supported vite.config.ts
1 parent 9dd9ad3 commit 61b76ef

File tree

3 files changed

+636
-52
lines changed

3 files changed

+636
-52
lines changed

encryption-decryption/browser/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"@vitejs/plugin-react-swc": "^3.7.0",
2121
"ethers": "v5",
2222
"react": "^18.3.1",
23-
"react-dom": "^18.3.1"
23+
"react-dom": "^18.3.1",
24+
"rollup-plugin-polyfill-node": "^0.13.0",
25+
"vite-plugin-node-polyfills": "^0.22.0"
2426
},
2527
"devDependencies": {
2628
"@types/react": "^18.3.3",
+40-22
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
1-
import { defineConfig } from "vite";
2-
import react from "@vitejs/plugin-react-swc";
3-
import { NodeGlobalsPolyfillPlugin } from "@esbuild-plugins/node-globals-polyfill";
4-
import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill";
1+
import { defineConfig } from 'vite';
2+
import react from '@vitejs/plugin-react';
3+
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
4+
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill';
5+
import rollupNodePolyFill from 'rollup-plugin-polyfill-node';
6+
import { nodePolyfills } from 'vite-plugin-node-polyfills';
57

68
export default defineConfig({
7-
plugins: [react()],
9+
plugins: [
10+
react(),
11+
nodePolyfills({
12+
include: ['buffer', 'process', 'util']
13+
}),
14+
],
815
define: {
9-
global: "window",
16+
'process.env': {},
17+
global: 'globalThis',
18+
},
19+
resolve: {
20+
alias: {
21+
// Remove the buffer alias
22+
},
23+
},
24+
optimizeDeps: {
25+
esbuildOptions: {
26+
define: {
27+
global: 'globalThis',
28+
},
29+
plugins: [
30+
NodeGlobalsPolyfillPlugin({
31+
buffer: true,
32+
process: true
33+
}),
34+
NodeModulesPolyfillPlugin(),
35+
],
36+
},
37+
},
38+
build: {
39+
rollupOptions: {
40+
plugins: [
41+
rollupNodePolyFill(),
42+
],
43+
},
1044
},
11-
optimizeDeps: {
12-
esbuildOptions: {
13-
// Node.js global to browser globalThis
14-
define: {
15-
global: "globalThis",
16-
},
17-
// Enable esbuild polyfill plugins
18-
plugins: [
19-
NodeGlobalsPolyfillPlugin({
20-
process: true,
21-
buffer: true,
22-
}),
23-
NodeModulesPolyfillPlugin(),
24-
],
25-
},
26-
},
2745
});

0 commit comments

Comments
 (0)