Files
pwap/web/vite.config.ts
T
SatoshiQaziMuhammed a1ad76e191 web: drop zod and @hookform/resolvers, which nothing imports; vite 7.3.7 (#63)
Neither package is imported anywhere in web/ or shared/. They reached the
production bundle only because vite.config.ts named them in the "forms"
manual chunk, which forces a module into the build whether or not any
code uses it. #61 moved zod to 4.6.7 to clear the advisory; removing it
takes the package out of the shipped bundle altogether (abitype declares
it as an optional peer, so nothing installs it). The "forms" chunk now
holds react-hook-form alone.

vite 7.3.7 (2026-10-06) closes the launch-editor advisories on 7.0.0-7.3.6
(Dependabot #313-#315). They reach only the dev server, but the alerts
are real. Typecheck ratchet 335/335, 32 tests, build green.
2026-10-26 17:45:44 +04:00

98 lines
4.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/// <reference types="vitest" />
import { defineConfig, configDefaults } from "vitest/config";
import react from "@vitejs/plugin-react-swc";
import path from "path";
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import subresourceIntegrity from 'vite-plugin-subresource-integrity';
// https://vitejs.dev/config/
export default defineConfig(({ command }) => ({
test: {
globals: true,
environment: 'jsdom',
setupFiles: './src/tests/setup.ts',
// supabase/** holds Deno tests (Deno.test + pglite) run via `deno test`,
// not vitest — exclude them from the web (node/jsdom) test sweep.
exclude: [...configDefaults.exclude, 'supabase/**'],
alias: {
'vite-plugin-node-polyfills/shims/buffer': path.resolve(__dirname, './src/tests/mocks/buffer-shim.ts'),
'vite-plugin-node-polyfills/shims/global': path.resolve(__dirname, './src/tests/mocks/global-shim.ts'),
'vite-plugin-node-polyfills/shims/process': path.resolve(__dirname, './src/tests/mocks/process-shim.ts'),
},
},
server: {
host: "::",
port: 8082,
strictPort: false, // Allow automatic port selection if 8082 is busy
hmr: {
protocol: 'ws',
host: 'localhost',
},
watch: {
usePolling: true,
},
},
plugins: [
react(),
nodePolyfills({
globals: {
Buffer: true,
global: true,
process: true,
},
protocolImports: true,
}),
// SRI: production build sırasında <script>/<link> tag'lerine
// sha384 integrity hash ekle. CDN/proxy compromise olsa bile
// tampered asset browser tarafından load edilmez.
command === 'build' ? subresourceIntegrity({ algorithm: 'sha384' }) : null,
].filter(Boolean),
resolve: {
mainFields: ['browser', 'module', 'main', 'exports'],
alias: {
// Rollup cannot resolve virtual shim modules in production — alias to real file.
// Dev mode: the plugin's own virtual module handles it; do NOT override it here.
...(command === 'build' ? {
'vite-plugin-node-polyfills/shims/process': path.resolve(__dirname, './src/lib/process-shim.ts'),
} : {}),
"@": path.resolve(__dirname, "./src"),
"@pezkuwi/i18n": path.resolve(__dirname, "../shared/i18n"),
"@pezkuwi/lib": path.resolve(__dirname, "../shared/lib"),
"@pezkuwi/utils": path.resolve(__dirname, "../shared/utils"),
"@pezkuwi/theme": path.resolve(__dirname, "../shared/theme"),
"@local/types": path.resolve(__dirname, "../shared/types"),
"@pezkuwi/components": path.resolve(__dirname, "../shared/components"),
"@shared": path.resolve(__dirname, "../shared"),
},
dedupe: ['react', 'lucide-react', 'sonner', '@pezkuwi/util-crypto', '@pezkuwi/util', '@pezkuwi/api', '@pezkuwi/extension-dapp', '@pezkuwi/keyring'],
},
optimizeDeps: {
include: ['@pezkuwi/util-crypto', '@pezkuwi/util', '@pezkuwi/api', '@pezkuwi/extension-dapp', '@pezkuwi/keyring', 'buffer'],
},
// Strip all console.* and debugger statements from production bundles so the
// 600+ dev-time console calls never ship. Dev keeps full logging.
esbuild: command === 'build' ? { drop: ['console', 'debugger'] } : {},
build: {
rollupOptions: {
external: [],
onwarn(warning, warn) {
// Suppress the buffer shim warning - it's handled by vite-plugin-node-polyfills
if (warning.message?.includes('vite-plugin-node-polyfills/shims/buffer')) {
return;
}
warn(warning);
},
output: {
manualChunks: {
'pezkuwi': ['@pezkuwi/api', '@pezkuwi/extension-dapp', '@pezkuwi/keyring', '@pezkuwi/util', '@pezkuwi/util-crypto'],
'vendor': ['react', 'react-dom', 'react-router-dom'],
'ui': ['@radix-ui/react-dialog', '@radix-ui/react-dropdown-menu', '@radix-ui/react-select', '@radix-ui/react-tabs', '@radix-ui/react-toast'],
'forms': ['react-hook-form'],
'i18n': ['i18next', 'react-i18next', 'i18next-browser-languagedetector']
}
}
},
chunkSizeWarningLimit: 600
},
// assetsInclude: ['**/*.json'], // Disabled: interferes with node_modules JSON imports (crypto-browserify)
}));