import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import * as path from 'path' export default defineConfig({ plugins: [ vue(), ], server: { host: '0.0.0.0', port: 8081, proxy: { // 代理所有以 /system 开头的请求 '/system': { target: 'http://192.168.1.176:8081', changeOrigin: true, // 可选:重写路径 rewrite: (path) => path.replace(/^\/system/, '/system') }, // 代理所有以 /api 开头的请求 '/api': { target: 'http://192.168.1.176:8081', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, '/api') }, '/perm': { target: 'http://192.168.1.176:8081', changeOrigin: true, rewrite: (path) => path.replace(/^\/perm/, '/perm') } } }, resolve: { alias: { '@': path.resolve(__dirname, 'src') }, }, build: { outDir: 'dist', // 输出目录 assetsDir: 'assets', // 静态资源目录 rollupOptions: { output: { // 将JS文件输出到assets目录 entryFileNames: 'assets/[name].[hash].js', chunkFileNames: 'assets/[name].[hash].js', // 将CSS、图片等资源输出到assets目录 assetFileNames: 'assets/[name].[hash].[ext]', // 禁用代码分割,将所有代码打包到一个文件中 manualChunks: undefined } } }, // server: { // host: '192.168.1.189', // 替换为你本机的实际IP地址 // port: 5173, // }, clearScreen: false, // 不清除屏幕,保持简洁输出 })