File size: 1,070 Bytes
5710dd0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
import { viteSingleFile } from 'vite-plugin-singlefile';
const apiPort = Number(process.env.PORT) || 5174;
const webPort = Number(process.env.WEB_PORT) || 5173;
// When set, build a single self-contained index.html (JS+CSS inlined) into
// `dist-single/` so it can be embedded into the kimi CLI. The normal `dist/`
// build is unaffected.
const singlefile = process.env.VIS_SINGLEFILE === '1';
export default defineConfig({
plugins: [
react(),
tailwindcss(),
...(singlefile
? [
viteSingleFile({
useRecommendedBuildConfig: true,
deleteInlinedFiles: true,
}),
]
: []),
],
server: {
port: webPort,
strictPort: false,
proxy: {
'/api': {
target: `http://localhost:${apiPort}`,
changeOrigin: true,
},
},
},
build: {
outDir: singlefile ? 'dist-single' : 'dist',
emptyOutDir: true,
target: 'es2022',
},
});
|