mirror of
https://github.com/talktao/Vue3-Vite-Vant-TS-H5.git
synced 2025-05-25 00:39:18 +08:00
feat:配置host
This commit is contained in:
parent
9ee91892ed
commit
2ef5ad0f03
@ -1,21 +1,21 @@
|
|||||||
import { defineConfig, loadEnv } from 'vite'
|
import { defineConfig, loadEnv } from 'vite';
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue';
|
||||||
import path from "path"
|
import path from "path";
|
||||||
import styleImport, { VantResolve } from 'vite-plugin-style-import';
|
import styleImport, { VantResolve } from 'vite-plugin-style-import';
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig(({command, mode})=>{
|
export default defineConfig(({ command, mode }) => {
|
||||||
// 检查process.cwd()路径下.env.develeport.local、.env.development、.env.local、.env这四个环境文件
|
// 检查process.cwd()路径下.env.develeport.local、.env.development、.env.local、.env这四个环境文件
|
||||||
loadEnv(mode, process.cwd())
|
loadEnv(mode, process.cwd());
|
||||||
return {
|
return {
|
||||||
|
|
||||||
// 静态资源基础路径 base: './' || '',
|
// 静态资源基础路径 base: './' || '',
|
||||||
base:'./',
|
base: './',
|
||||||
|
|
||||||
resolve: {
|
resolve: {
|
||||||
alias:{
|
alias: {
|
||||||
// 配置src目录
|
// 配置src目录
|
||||||
"@": path.resolve(__dirname,"src"),
|
"@": path.resolve(__dirname, "src"),
|
||||||
// 导入其他目录
|
// 导入其他目录
|
||||||
"components": path.resolve(__dirname, "components")
|
"components": path.resolve(__dirname, "components")
|
||||||
}
|
}
|
||||||
@ -31,13 +31,14 @@ export default defineConfig(({command, mode})=>{
|
|||||||
|
|
||||||
|
|
||||||
// 跨域代理
|
// 跨域代理
|
||||||
server:{
|
server: {
|
||||||
proxy:{
|
host: '0.0.0.0',
|
||||||
|
proxy: {
|
||||||
//这里是通过请求/api 来转发到 https://api.pingping6.com/
|
//这里是通过请求/api 来转发到 https://api.pingping6.com/
|
||||||
//假如你要请求https://api.*.com/a/a
|
//假如你要请求https://api.*.com/a/a
|
||||||
//那么axios的url,可以配置为 /api/a/a
|
//那么axios的url,可以配置为 /api/a/a
|
||||||
'/api': ''
|
'/api': ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user