From 9055443dc6a29d71dce4e46897a88bd1f905337f Mon Sep 17 00:00:00 2001 From: Alexander Mangel Date: Thu, 19 Oct 2023 17:07:17 -0500 Subject: [PATCH] feat: polyfills for buffer etc --- packages/client/vite.config.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/client/vite.config.ts b/packages/client/vite.config.ts index 720ae66..44778b3 100644 --- a/packages/client/vite.config.ts +++ b/packages/client/vite.config.ts @@ -1,22 +1,36 @@ import { fileURLToPath } from "url"; import react from "@vitejs/plugin-react-swc"; import { defineConfig } from "vite"; +import nodePolyfills from "vite-plugin-node-stdlib-browser"; +import rollupNodePolyFill from "rollup-plugin-node-polyfills"; export default defineConfig({ - plugins: [react()], + plugins: [react(), nodePolyfills()], server: { port: 3000, fs: {}, }, resolve: { alias: { - // for TypeScript path alias import like : @/x/y/z + process: "process/browser", + stream: "stream-browserify", + zlib: "browserify-zlib", + util: "util", + buffer: "buffer", + events: "events", "@": fileURLToPath(new URL("./src", import.meta.url)), }, }, build: { + rollupOptions: { + plugins: [rollupNodePolyFill()], + }, target: "es2022", minify: true, sourcemap: true, }, + optimizeDeps: { + // exclude: ["@ethersproject/hash", "wrtc"], + // include: ["js-sha3", "@ethersproject/bignumber"], + }, });