Files
app_03_pregnancy/frontend/vite.config.ts

53 lines
1.5 KiB
TypeScript
Raw Permalink 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.
import { defineConfig, loadEnv } from 'vite'
import path from 'path'
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react'
import basicSsl from '@vitejs/plugin-basic-ssl'
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const apiPrefix = env.VITE_API_PREFIX || '/api'
const uploadsPrefix = env.VITE_UPLOADS_PREFIX || '/uploads'
return {
base: '/app_03/',
plugins: [
// The React and Tailwind plugins are both required for Make, even if
// Tailwind is not being actively used – do not remove them
react(),
tailwindcss(),
// basicSsl(), // disabled for cloudflare tunnel compatibility
],
resolve: {
alias: {
// Alias @ to the src directory
'@': path.resolve(__dirname, './src'),
},
},
// File types to support raw imports. Never add .css, .tsx, or .ts files to this.
assetsInclude: ['**/*.svg', '**/*.csv'],
build: {
// 使用 esbuild 代替 terser 避免变量名 mangling 导致 ReferenceError
minify: 'esbuild',
},
server: {
host: '0.0.0.0',
allowedHosts: ['.trycloudflare.com', '.loca.lt'],
proxy: {
[apiPrefix]: {
target: 'http://localhost:8030',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/app_03\/api/, '/api'),
},
[uploadsPrefix]: {
target: 'http://localhost:8030',
changeOrigin: true,
},
},
},
}
})