提交 03f0b5f7 编写于 作者: 郝先瑞

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

上级 561ed597
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 }
} }
} };
} };
)
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册