import { fileURLToPath, URL } from 'node:url' import { defineConfig, loadEnv } from 'vite' import vue from '@vitejs/plugin-vue' import eslint from 'vite-plugin-eslint' // https://vitejs.dev/config/ export default ({mode}) => { const apiPrefix = loadEnv(mode, process.cwd()).VITE_APP_API_PREFIX const apiUrl = 'http://82.157.20.36:10010';//loadEnv(mode, process.cwd()).VITE_APP_API_URL return defineConfig({ plugins: [ vue(), eslint({ include: ['src/**/*.js', 'src/**/*.vue'], exclude: ['node_modules'] }) ], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) }, extensions: ['.vue', '.js'] }, server: { host: '0.0.0.0', port: 10086, proxy: { // 接口代理 [apiPrefix]: { target: apiUrl, changeOrigin: true, rewrite: (path) => path.replace(new RegExp(`^${apiPrefix}`), "") }, // 静态资源代理 '/resource': { target: apiUrl, changeOrigin: true } } } }) }