1 Star 0 Fork 0

TxsLs/学习vue-admin-box前端

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
vite.config.ts 2.17 KB
一键复制 编辑 原始数据 按行查看 历史
TxsLs 提交于 2024-03-27 20:58 . 研究了一下这个模板--==20240327
/*
* @Author: luoxi
* @Date: 2022-01-25 09:51:12
* @LastEditors: Please set LastEditors
* @LastEditTime: 2023-02-21 22:57:42
* @FilePath: \vue-admin-box\vite.config.ts
* @Description:
*/
import { ConfigEnv, UserConfigExport } from 'vite'
import vue from '@vitejs/plugin-vue'
import { viteMockServe } from 'vite-plugin-mock'
import {vitePluginSvg} from "@webxrd/vite-plugin-svg"
import { resolve } from 'path'
const pathResolve = (dir: string): any => {
return resolve(__dirname, ".", dir)
}
const alias: Record<string, string> = {
'@': pathResolve("src")
}
/**
* @description-en vite document address
* @description-cn vite官网
* https://vitejs.cn/config/ */
export default ({ command }: ConfigEnv): UserConfigExport => {
const prodMock = true;
return {
base: './',
resolve: {
alias
},
server: {
port: 5500,
host: '0.0.0.0',
open: false,
proxy: { // 代理配置
'/dev': 'https://www.fastmock.site/mock/48cab8545e64d93ff9ba66a87ad04f6b/'
},
},
build: {
rollupOptions: {
output: {
manualChunks: {
'echarts': ['echarts']
}
}
}
},
plugins: [
vue(),
viteMockServe({
mockPath: 'mock',
localEnabled: command === 'serve',
prodEnabled: command !== 'serve' && prodMock,
watchFiles: true,
injectCode: `
import { setupProdMockServer } from '../mockProdServer';
setupProdMockServer();
`,
logger: true,
}),
vitePluginSvg({
// 必要的。必须是绝对路径组成的数组。
iconDirs: [
resolve(__dirname, 'src/assets/svg'),
],
// 必要的。入口script
main: resolve(__dirname, 'src/main.js'),
symbolIdFormat: 'icon-[name]'
}),
],
css: {
postcss: {
plugins: [
{
postcssPlugin: 'internal:charset-removal',
AtRule: {
charset: (atRule) => {
if (atRule.name === 'charset') {
atRule.remove();
}
}
}
}
],
},
}
};
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/TxsLS/learning-vue-front-end.git
git@gitee.com:TxsLS/learning-vue-front-end.git
TxsLS
learning-vue-front-end
学习vue-admin-box前端
master

搜索帮助