Skip to content

Commit

Permalink
fix vite bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zamrokk committed Sep 29, 2023
1 parent 787b16d commit f9c6680
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions solution/app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
import react from "@vitejs/plugin-react-swc";
import path from "path";
import { defineConfig } from "vite";

// https://vitejs.dev/config/
export default defineConfig({
define: {
global: {},
},
plugins: [react()],
resolve: {
alias: {
stream: "stream-browserify",
os: "os-browserify/browser",
util: "util",
process: "process/browser",
buffer: "buffer",
export default ({ command }) => {
const isBuild = command === "build";

return defineConfig({
define: {},
plugins: [react()],
build: {
commonjsOptions: {
transformMixedEsModules: true,
},
},
resolve: {
alias: {
// dedupe @airgap/beacon-sdk
// I almost have no idea why it needs `cjs` on dev and `esm` on build, but this is how it works 🤷‍♂️
"@airgap/beacon-sdk": path.resolve(
path.resolve(),
`./node_modules/@airgap/beacon-sdk/dist/${
isBuild ? "esm" : "cjs"
}/index.js`
),
stream: "stream-browserify",
os: "os-browserify/browser",
util: "util",
process: "process/browser",
buffer: "buffer",
crypto: "crypto-browserify",
assert: "assert",
http: "stream-http",
https: "https-browserify",
url: "url",
path: "path-browserify",
},
},
},
});
});
};

0 comments on commit f9c6680

Please sign in to comment.