Import project configuration: app/vite.config.js

Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality.
This commit is contained in:
arsam
2026-09-18 23:17:53 +03:30
parent a579e7ec4f
commit 46d5fd0b0c
+52
View File
@@ -0,0 +1,52 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
// Vite config: bundles React + JSX at build time (no CDN, no Babel-Standalone),
// emits hashed assets, copies /public/* (incl. fonts) to dist/.
export default defineConfig({
root: '.',
publicDir: 'public',
server: {
port: 3009,
host: '0.0.0.0',
strictPort: true,
proxy: {
// Forward /api/* to the Fastify backend so the browser sees same-origin
// cookies in dev. Production goes through Caddy with the same path-based
// routing — the frontend code never needs to know which is in use.
'/api': {
target: 'http://localhost:3010',
changeOrigin: false,
},
},
},
preview: { port: 3009, host: '0.0.0.0', strictPort: true },
build: {
outDir: 'dist',
sourcemap: true,
target: 'es2020',
cssCodeSplit: true,
// Keep imported icon SVGs as real hashed files (never base64-inlined) so they
// serve from /assets/ with gzip_static/brotli_static and CSS mask URLs stay clean.
assetsInlineLimit(filePath) {
if (filePath.includes('assets/icons/')) return false;
// any other asset → Vite's default size-based inlining
},
rollupOptions: {
input: {
main: 'index.html',
embed: 'embed.html',
},
output: {
// Group React separately so the vendor bundle is cacheable across deploys.
manualChunks(id) {
if (id.includes('node_modules/react')) return 'vendor-react';
if (id.includes('node_modules/three')) return 'vendor-three';
if (id.includes('node_modules/d3') || id.includes('node_modules/d3-')) return 'vendor-d3';
if (id.includes('node_modules')) return 'vendor';
},
},
},
},
plugins: [react()],
});