From 03f0b5f75f8f612be2c390525e86b970f5279bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=9D=E5=85=88=E7=91=9E?= <1490493387@qq.com> Date: Wed, 4 May 2022 15:01:20 +0800 Subject: [PATCH] =?UTF-8?q?fix(vite.config.ts):=20eslint=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.ts | 78 ++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 0fb3d59..44f5835 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,44 +1,42 @@ -import { UserConfig, ConfigEnv, loadEnv } from 'vite' -import vue from '@vitejs/plugin-vue' -import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' -import path from 'path' +import { UserConfig, ConfigEnv, loadEnv } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'; +import path from 'path'; // @see: https://gitee.com/holysheng/vite2-config-description/blob/master/vite.config.ts export default ({ command, mode }: ConfigEnv): UserConfig => { - // 获取 .env 环境配置文件 - const env = loadEnv(mode, process.cwd()) + // 获取 .env 环境配置文件 + const env = loadEnv(mode, process.cwd()); - return ( - { - plugins: [ - vue(), - createSvgIconsPlugin({ - // 指定需要缓存的图标文件夹 - iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')], - // 指定symbolId格式 - symbolId: 'icon-[dir]-[name]' - }) - - ], - // 本地反向代理解决浏览器跨域限制 - server: { - host: 'localhost', - port: Number(env.VITE_APP_PORT), - open: true, // 运行自动打开浏览器 - proxy: { - [env.VITE_APP_BASE_API]: { - target: 'http://www.youlai.tech:9999', - changeOrigin: true, - rewrite: path => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '') - } - } - }, - resolve: { - // Vite路径别名配置 - alias: { - "@": path.resolve("./src"), // @代替src - } - } - } - ) -} \ No newline at end of file + return { + plugins: [ + vue(), + createSvgIconsPlugin({ + // 指定需要缓存的图标文件夹 + iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')], + // 指定symbolId格式 + symbolId: 'icon-[dir]-[name]' + }) + ], + // 本地反向代理解决浏览器跨域限制 + server: { + host: 'localhost', + port: Number(env.VITE_APP_PORT), + open: true, // 运行自动打开浏览器 + proxy: { + [env.VITE_APP_BASE_API]: { + target: 'http://www.youlai.tech:9999', + changeOrigin: true, + rewrite: path => + path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '') + } + } + }, + resolve: { + // Vite路径别名配置 + alias: { + '@': path.resolve('./src') // @代替src + } + } + }; +}; -- GitLab