2026-05-22 12:41:55 +00:00
|
|
|
import react from '@vitejs/plugin-react';
|
2026-06-02 02:42:07 +07:00
|
|
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
2026-05-22 12:41:55 +00:00
|
|
|
import path from 'node:path';
|
2026-05-22 21:53:01 +00:00
|
|
|
import { defineConfig, loadEnv } from 'vite';
|
2026-06-07 18:06:19 +07:00
|
|
|
import { metricsPlugin } from './vite-plugin-metrics';
|
2026-05-22 12:41:55 +00:00
|
|
|
|
2026-05-22 21:53:01 +00:00
|
|
|
export default defineConfig(({ mode }) => {
|
|
|
|
|
const env = loadEnv(mode, process.cwd(), '');
|
|
|
|
|
const apiProxyTarget = env.VITE_API_PROXY_TARGET || 'http://localhost:3000';
|
|
|
|
|
|
|
|
|
|
return {
|
2026-06-15 23:00:30 +07:00
|
|
|
plugins: [
|
|
|
|
|
react(),
|
|
|
|
|
tsconfigPaths(),
|
|
|
|
|
metricsPlugin(),
|
|
|
|
|
{
|
|
|
|
|
name: 'cloudflare-rocket-loader-fix',
|
|
|
|
|
transformIndexHtml(html) {
|
|
|
|
|
// Prevent Cloudflare Rocket Loader from mangling <script type="module">
|
|
|
|
|
// which breaks the entire JS bundle (blank page)
|
|
|
|
|
return html.replace(
|
|
|
|
|
/<script type="module"/g,
|
|
|
|
|
'<script data-cfasync="false" type="module"',
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
2026-05-22 21:53:01 +00:00
|
|
|
server: {
|
|
|
|
|
proxy: {
|
|
|
|
|
'/api': apiProxyTarget,
|
|
|
|
|
},
|
2026-05-22 18:50:07 +00:00
|
|
|
},
|
2026-05-22 21:53:01 +00:00
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'@': path.resolve(__dirname, './src'),
|
|
|
|
|
},
|
2026-05-22 12:41:55 +00:00
|
|
|
},
|
2026-05-22 21:53:01 +00:00
|
|
|
};
|
2026-05-22 12:41:55 +00:00
|
|
|
});
|