-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
46 lines (45 loc) · 1.38 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
import GlobalPolyFill, { NodeGlobalsPolyfillPlugin } from "@esbuild-plugins/node-globals-polyfill";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import postcss from './postcss.config.js'
import NodeModulesPolyfillPlugin from "@esbuild-plugins/node-modules-polyfill";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import commonjs from "vite-plugin-commonjs";
export default defineConfig({
css: {
postcss: postcss,
},
plugins: [react(),
NodeGlobalsPolyfillPlugin({
buffer: true,
process: true,
}),
nodePolyfills(),
NodeModulesPolyfillPlugin(),
commonjs({
include: /node_modules/,
requireReturnsDefault: 'auto', // <---- this solves default issue
}),
],
build: {
commonjsOptions: {
transformMixedEsModules: true,
},
rollupOptions: {
plugins: [
nodePolyfills(), // Add it to rollupOptions as well for production build
],
},
},
resolve: {
alias: {
// process: "process/browser",
process: 'rollup-plugin-node-polyfills/polyfills/process-es6.js',
stream: "stream-browserify",
zlib: "browserify-zlib",
util: "util",
crypto: "crypto-browserify",
Buffer:'buffer'
},
},
});