Add node polyfills (#1093)
* Add node polyfills * remove unused polyfill * enable fs in node polyfill * remove polyfill aliases and crypto * Fix build error * Fix buffer injection
This commit is contained in:
@@ -2,6 +2,8 @@ import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { wasm } from '@rollup/plugin-wasm';
|
||||
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
||||
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
|
||||
import inject from '@rollup/plugin-inject';
|
||||
import { svgLoader } from './viteSvgLoader';
|
||||
|
||||
const copyFiles = {
|
||||
@@ -39,9 +41,28 @@ export default defineConfig({
|
||||
wasm(),
|
||||
react(),
|
||||
],
|
||||
optimizeDeps: {
|
||||
esbuildOptions: {
|
||||
define: {
|
||||
global: 'globalThis'
|
||||
},
|
||||
plugins: [
|
||||
// Enable esbuild polyfill plugins
|
||||
NodeGlobalsPolyfillPlugin({
|
||||
process: false,
|
||||
buffer: true,
|
||||
}),
|
||||
]
|
||||
}
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
sourcemap: true,
|
||||
copyPublicDir: false,
|
||||
rollupOptions: {
|
||||
plugins: [
|
||||
inject({ Buffer: ['buffer', 'Buffer'] })
|
||||
]
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user