1 Star 0 Fork 24

LaughterLanling/exam-web

forked from ForTheExam/exam-web 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.js 2.97 KB
一键复制 编辑 原始数据 按行查看 历史
Baymax 提交于 2023-02-22 20:20 . 优化细节,基本完成功能
import { defineConfig,loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
// import OptimizationPersist from 'vite-plugin-optimize-persist'
// import PkgConfig from 'vite-plugin-package-config'
// import Components from 'unplugin-vue-components/vite';
// import { ArcoResolver } from 'unplugin-vue-components/resolvers';
import vitePluginForArco from '@arco-plugins/vite-vue'
// import svgLoader from 'vite-svg-loader'
const { resolve } = require('path')
// https://vitejs.dev/config/
export default ({ mode })=>{
const app_ip=loadEnv(mode, process.cwd()).VITE_API_HOST_IP
const app_host=`http://${app_ip}`
const user_path=loadEnv(mode, process.cwd()).VITE_USER_API_URL
const exam_path=loadEnv(mode, process.cwd()).VITE_EXAM_API_URL
const auth_path=loadEnv(mode, process.cwd()).VITE_AUTH_API_URL
const message_path=loadEnv(mode, process.cwd()).VITE_MESSAGE_API_URL
const file_path=loadEnv(mode, process.cwd()).VITE_FILE_API_URL
return defineConfig({
plugins: [
vue(),
// PkgConfig(),
// OptimizationPersist()
// svgLoader(),
//按需加载
vitePluginForArco({
theme:'@arco-themes/vue-mgo-blog',
style: 'css',
// iconPrefix:'icon'
}),
],
server: {
open: '/',
port:3030,
host: '0.0.0.0' ,
proxy: {
//用户微服务
'/uapi': {
target: app_host,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/uapi/, user_path)
},
'/aapi': {
target: app_host,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/aapi/, auth_path)
},
//考试微服务
'/eapi': {
target: app_host,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/eapi/, exam_path)
},
'/mapi': {
target: app_host,
changeOrigin: true,//是否允许跨域
rewrite: (path) => path.replace(/^\/mapi/, message_path),
},
'/fapi': {
target: app_host,
changeOrigin: true,//是否允许跨域
rewrite: (path) => path.replace(/^\/fapi/, file_path),
},
// 代理websocket请求
'/mapi-scoket': {
target: `ws://${app_ip}`,
changeOrigin: true,//是否允许跨域
rewrite: (path) => path.replace(/^\/mapi-scoket/, message_path),
ws: true //开启ws
}
}
},
resolve: {
alias: [//配置别名
{ find: '@', replacement: resolve(__dirname, 'src') },
{ find: '@views', replacement: resolve(__dirname, 'src/views') }
],
// 情景导出 package.json 配置中的exports字段
conditions: [],
// 导入时想要省略的扩展名列表
// 不建议使用 .vue 影响IDE和类型支持
extensions:['.mjs','.js','.ts','.jsx','.tsx','.json']
},
})
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/laughter_lanling/exam-web.git
git@gitee.com:laughter_lanling/exam-web.git
laughter_lanling
exam-web
exam-web
master

搜索帮助