From d727617b0efd6150eeecaccb527870e90ad92c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=9D=E5=85=88=E7=91=9E?= <1490493387@qq.com> Date: Sat, 1 Jan 2022 15:57:05 +0800 Subject: [PATCH] =?UTF-8?q?refactor(vite.config.ts):=20Vite=E5=88=AB?= =?UTF-8?q?=E5=90=8D=E4=BD=BF=E7=94=A8=E6=96=B9=E5=BC=8F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.ts | 76 +++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 7f25b631..1df33b9d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -22,7 +22,7 @@ export default ({command, mode}: ConfigEnv): UserConfig => { }) ], - // 本地反向代理解决跨域 + // 本地反向代理解决浏览器跨域限制 server: { host: 'localhost', port: Number(env.VITE_APP_PORT), @@ -38,44 +38,44 @@ export default ({command, mode}: ConfigEnv): UserConfig => { resolve: { // Vite2设置别名路径方式一 - // alias:{ - // "/@":path.resolve("./src"), // 相对路径别名配置,@表示src - // }, + alias: { + "@": path.resolve("./src"), // 相对路径别名配置,@表示src + }, // Vite2设置别名路径方式二 - alias: [ - { - find: "@", - replacement: path.resolve("./src") - }, - { - find: "@image", - replacement: path.resolve("./src/assets/images") - }, - { - find: "@router", - replacement: path.resolve("./src/router") - }, - { - find: "@store", - replacement: path.resolve("./src/store") - }, - { - find: "@api", - replacement: path.resolve("./src/api") - }, - { - find: "@utils", - replacement: path.resolve("./src/utils") - }, - { - find: "@views", - replacement: path.resolve("./src/views") - }, - { - find: "@styles", - replacement: path.resolve("./src/styles") - }, - ] + // alias: [ + // { + // find: "@", + // replacement: path.resolve("./src") + // }, + // { + // find: "@image", + // replacement: path.resolve("./src/assets/images") + // }, + // { + // find: "@/router", + // replacement: path.resolve("./src/router") + // }, + // { + // find: "@/store", + // replacement: path.resolve("./src/store") + // }, + // { + // find: "@/api", + // replacement: path.resolve("./src/api") + // }, + // { + // find: "@/utils", + // replacement: path.resolve("./src/utils") + // }, + // { + // find: "@/views", + // replacement: path.resolve("./src/views") + // }, + // { + // find: "@/styles", + // replacement: path.resolve("./src/styles") + // }, + // ] } }