import eslint from '@nabla/vite-plugin-eslint'; import react from '@vitejs/plugin-react'; import unocss from 'unocss/vite'; import { defineConfig, loadEnv } from 'vite'; import mkcert from 'vite-plugin-mkcert'; import topLevelAwait from 'vite-plugin-top-level-await'; import tsPaths from 'vite-plugin-tsconfig-paths'; // const ReactCompilerConfig = {}; // https://vite.dev/config/ export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), ''); return { base: '/', plugins: [ react({ babel: { // plugins: [['babel-plugin-react-compiler', ReactCompilerConfig]], }, }), unocss(), eslint({ eslintOptions: { cache: false } }), topLevelAwait(), tsPaths(), mkcert({ savePath: './certs', // save the generated certificate into certs directory }), ], server: { https: { cert: './certs/cert.pem', key: './certs/dev.pem' }, cors: true, proxy: { '/api': { target: env.API_SERVER ?? 'http://localhost:3001', changeOrigin: true, secure: false, }, '/auth': { target: env.AUTH_SERVER ?? 'http://localhost:3000/auth', changeOrigin: true, secure: false, rewrite: (path) => path.replace(/^\/auth/, ''), }, }, }, }; });