2 Star 25 Fork 4

chried/scui-plus

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.js 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
gaoweibing 提交于 2024-03-06 14:12 +08:00 . [ADD]全局改动
import {fileURLToPath, URL} from 'node:url'
import {defineConfig, loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default ({mode}) => {
const env = loadEnv(mode, process.cwd());
return defineConfig({
server: {
proxy: {
"/api": {
target: env.VITE_VUE_APP_API_BASEURL,
changeOrigin: true,
rewrite: (path) => path.replace(new RegExp('^/api'), '/'),
secure: false,
configure: (proxy, options) => {
// 配置此项可在响应头中看到请求的真实地址
proxy.on('proxyRes', (proxyRes, req) => {
proxyRes.headers['x-real-url'] = new URL(req.url || '', options?.target)?.href || ''
})
},
},
},
}, plugins: [vue(), AutoImport({
resolvers: [ElementPlusResolver()], imports: ['vue', 'vue-router',],
}), Components({
// 配置需要自动注册的组件
dts: true, resolvers: [(name) => {
if (name.startsWith('sc')) {
return {importName: name.slice(4), path: `@/components/${name}/index.vue`}
}
}, ElementPlusResolver(),],
})], resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}, define: {
'process.env': {...process.env}
}, build: {
commonjsOptions: {transformMixedEsModules: true} // Change
}
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/euyan/scui-plus.git
git@gitee.com:euyan/scui-plus.git
euyan
scui-plus
scui-plus
master

搜索帮助