mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-09-13 14:22:25 +03:00
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:
parent
3ad143228d
commit
374d2d1962
3 changed files with 162 additions and 0 deletions
|
@ -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'] })
|
||||
]
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue