2026-01-05 17:06:16 +08:00
|
|
|
|
import path from 'node:path';
|
2026-01-06 14:10:24 +08:00
|
|
|
|
import react from '@vitejs/plugin-react';
|
2026-01-05 17:06:16 +08:00
|
|
|
|
// import { visualizer } from 'rollup-plugin-visualizer';
|
|
|
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
|
|
|
|
|
|
|
|
// https://vite.dev/config/
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
|
plugins: [
|
|
|
|
|
|
react(), // 打包后生成体积分析报告(dist/stats.html)
|
|
|
|
|
|
// visualizer({
|
|
|
|
|
|
// // open: true, // 自动打开报告页面
|
|
|
|
|
|
// filename: 'stats.html',
|
|
|
|
|
|
// }),
|
|
|
|
|
|
],
|
|
|
|
|
|
base: './',
|
|
|
|
|
|
resolve: {
|
|
|
|
|
|
alias: {
|
|
|
|
|
|
'@': path.resolve(__dirname, './src'),
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
server: {
|
|
|
|
|
|
port: 4050,
|
|
|
|
|
|
host: '0.0.0.0',
|
|
|
|
|
|
proxy: {
|
|
|
|
|
|
'/api': {
|
2026-01-16 16:47:12 +08:00
|
|
|
|
target: 'http://www.free.loc',
|
2026-01-05 17:06:16 +08:00
|
|
|
|
changeOrigin: true,
|
|
|
|
|
|
rewrite: (path) => path.replace(/^\/api/, ''), // 不可以省略rewrite
|
|
|
|
|
|
},
|
|
|
|
|
|
'/static': {
|
2026-01-27 14:04:37 +08:00
|
|
|
|
target: 'http://www.free.loc',
|
2026-01-05 17:06:16 +08:00
|
|
|
|
changeOrigin: true,
|
|
|
|
|
|
rewrite: (path) => path.replace(/^\/api/, ''), // 不可以省略rewrite
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|