Update vite.config.ts

This commit is contained in:
Ryan MacArthur
2024-03-13 19:22:56 +08:00
committed by GitHub
parent 458bb28272
commit c909eef1e5

View File

@@ -1,8 +1,17 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { nodePolyfills } from 'vite-plugin-node-polyfills';
export default defineConfig({
plugins: [react()],
plugins: [react(),
nodePolyfills({
include: ["buffer"],
globals: {
Buffer: true,
},
}),
],
server: {
port: 3000,
fs: {
@@ -13,5 +22,15 @@ export default defineConfig({
target: "es2022",
minify: true,
sourcemap: true,
rollupOptions: {
plugins: [
inject({
// cbor-x checks for Buffer on the global object, and the polyfills plugin doesn't cover this case for the
// production build (but works in development because Buffer gets injected as a banner, so it's "naturally"
// available on the global object)
"globalThis.Buffer": ["buffer", "Buffer"],
}),
],
},
},
});