From 2ef5ad0f03e749b017b438f6ff98be32df2cc79b Mon Sep 17 00:00:00 2001 From: tantao <1416249906@qq.com> Date: Thu, 25 Aug 2022 14:41:15 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E9=85=8D=E7=BD=AEhost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.ts | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index ab14edd..1753505 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,43 +1,44 @@ -import { defineConfig, loadEnv } from 'vite' -import vue from '@vitejs/plugin-vue' -import path from "path" +import { defineConfig, loadEnv } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import path from "path"; import styleImport, { VantResolve } from 'vite-plugin-style-import'; // https://vitejs.dev/config/ -export default defineConfig(({command, mode})=>{ +export default defineConfig(({ command, mode }) => { // 检查process.cwd()路径下.env.develeport.local、.env.development、.env.local、.env这四个环境文件 - loadEnv(mode, process.cwd()) + loadEnv(mode, process.cwd()); return { - + // 静态资源基础路径 base: './' || '', - base:'./', - + base: './', + resolve: { - alias:{ + alias: { // 配置src目录 - "@": path.resolve(__dirname,"src"), + "@": path.resolve(__dirname, "src"), // 导入其他目录 "components": path.resolve(__dirname, "components") } }, plugins: [ - vue(), - // 配置后,Vant各组件才生效 - styleImport({ - resolves: [VantResolve()], - }), + vue(), + // 配置后,Vant各组件才生效 + styleImport({ + resolves: [VantResolve()], + }), ], - - + + // 跨域代理 - server:{ - proxy:{ + server: { + host: '0.0.0.0', + proxy: { //这里是通过请求/api 来转发到 https://api.pingping6.com/ //假如你要请求https://api.*.com/a/a //那么axios的url,可以配置为 /api/a/a '/api': '' - } + } } - } -}) + }; +});