fix(vite.config.ts): eslint代码检查优化
Former-commit-id: 03f0b5f75f8f612be2c390525e86b970f5279bea
This commit is contained in:
@@ -1,44 +1,42 @@
|
|||||||
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({
|
// 指定需要缓存的图标文件夹
|
||||||
// 指定需要缓存的图标文件夹
|
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
|
||||||
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
|
// 指定symbolId格式
|
||||||
// 指定symbolId格式
|
symbolId: 'icon-[dir]-[name]'
|
||||||
symbolId: 'icon-[dir]-[name]'
|
})
|
||||||
})
|
],
|
||||||
|
// 本地反向代理解决浏览器跨域限制
|
||||||
],
|
server: {
|
||||||
// 本地反向代理解决浏览器跨域限制
|
host: 'localhost',
|
||||||
server: {
|
port: Number(env.VITE_APP_PORT),
|
||||||
host: 'localhost',
|
open: true, // 运行自动打开浏览器
|
||||||
port: Number(env.VITE_APP_PORT),
|
proxy: {
|
||||||
open: true, // 运行自动打开浏览器
|
[env.VITE_APP_BASE_API]: {
|
||||||
proxy: {
|
target: 'http://www.youlai.tech:9999',
|
||||||
[env.VITE_APP_BASE_API]: {
|
changeOrigin: true,
|
||||||
target: 'http://www.youlai.tech:9999',
|
rewrite: path =>
|
||||||
changeOrigin: true,
|
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
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user