mirror of
https://github.com/hanzo-apps/vote.git
synced 2026-10-30 20:00:39 +00:00
web3modal/wagmi/viem expect Node globals at runtime; without this the bundle throws 'Buffer is not defined' on load. Globals-only keeps the polyfill surface minimal. Branding already Hanzo on main. Co-authored-by: Hanzo Dev <[email protected]>
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { sentryVitePlugin } from '@sentry/vite-plugin';
|
|
import { viteWranglerSpa } from '@torchauth/vite-plugin-wrangler-spa';
|
|
import react from '@vitejs/plugin-react-swc';
|
|
import { defineConfig, loadEnv } from 'vite';
|
|
import { checker } from 'vite-plugin-checker';
|
|
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
|
import packageJson from './package.json';
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '');
|
|
const plugins = [
|
|
react(),
|
|
// Browser polyfills for Node globals (Buffer/global/process) that
|
|
// web3modal/wagmi/viem expect at runtime; without this the bundle
|
|
// throws "Buffer is not defined" on load.
|
|
nodePolyfills({ globals: { Buffer: true, global: true, process: true } }),
|
|
viteWranglerSpa(),
|
|
];
|
|
if (env.SENTRY_ORG && env.SENTRY_PROJECT && env.SENTRY_AUTH_TOKEN) {
|
|
console.log('Got Sentry credentials');
|
|
console.log(`Will upload sourcemaps for ${env.SENTRY_ORG}/${env.SENTRY_PROJECT}\n`);
|
|
plugins.push(
|
|
sentryVitePlugin({
|
|
org: env.SENTRY_ORG,
|
|
project: env.SENTRY_PROJECT,
|
|
authToken: env.SENTRY_AUTH_TOKEN,
|
|
sourcemaps: {
|
|
filesToDeleteAfterUpload: '**/*.map',
|
|
},
|
|
telemetry: false,
|
|
}),
|
|
);
|
|
}
|
|
return {
|
|
plugins,
|
|
base: process.env.GITHUB_ACTIONS ? '/vote/' : '/',
|
|
server: {
|
|
port: 3000,
|
|
},
|
|
build: {
|
|
sourcemap: true,
|
|
},
|
|
define: {
|
|
'import.meta.env.PACKAGE_VERSION': JSON.stringify(packageJson.version),
|
|
},
|
|
};
|
|
});
|