nankai-cms-admin/vite.config.js

43 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2025-03-13 09:50:20 +08:00
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
2025-03-13 10:15:54 +08:00
const apiUrl = 'http://82.157.20.36:10010';//loadEnv(mode, process.cwd()).VITE_APP_API_URL
2025-03-13 09:50:20 +08:00
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
}
}
}
})
}