fix(vite.config.ts): eslint代码检查优化

Former-commit-id: 03f0b5f75f8f612be2c390525e86b970f5279bea
This commit is contained in:
郝先瑞
2022-05-04 15:01:20 +08:00
parent eafc72d9d1
commit d5659e4be3

View File

@@ -1,15 +1,14 @@
import { UserConfig, ConfigEnv, loadEnv } from 'vite' import { UserConfig, ConfigEnv, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import path from 'path' import path from 'path';
// @see: https://gitee.com/holysheng/vite2-config-description/blob/master/vite.config.ts // @see: https://gitee.com/holysheng/vite2-config-description/blob/master/vite.config.ts
export default ({ command, mode }: ConfigEnv): UserConfig => { export default ({ command, mode }: ConfigEnv): UserConfig => {
// 获取 .env 环境配置文件 // 获取 .env 环境配置文件
const env = loadEnv(mode, process.cwd()) const env = loadEnv(mode, process.cwd());
return ( return {
{
plugins: [ plugins: [
vue(), vue(),
createSvgIconsPlugin({ createSvgIconsPlugin({
@@ -18,7 +17,6 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
// 指定symbolId格式 // 指定symbolId格式
symbolId: 'icon-[dir]-[name]' symbolId: 'icon-[dir]-[name]'
}) })
], ],
// 本地反向代理解决浏览器跨域限制 // 本地反向代理解决浏览器跨域限制
server: { server: {
@@ -29,16 +27,16 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
[env.VITE_APP_BASE_API]: { [env.VITE_APP_BASE_API]: {
target: 'http://www.youlai.tech:9999', target: 'http://www.youlai.tech:9999',
changeOrigin: true, changeOrigin: true,
rewrite: path => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '') rewrite: path =>
path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '')
} }
} }
}, },
resolve: { resolve: {
// Vite路径别名配置 // Vite路径别名配置
alias: { alias: {
"@": path.resolve("./src"), // @代替src '@': path.resolve('./src') // @代替src
} }
} }
} };
) };
}