1 Star 0 Fork 45

openex/element-plus-admin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.ts 2.69 KB
一键复制 编辑 原始数据 按行查看 历史
hsiangleev 提交于 2022-02-23 16:59 . element-plus依赖更新
import { UserConfigExport, ConfigEnv, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { viteMockServe } from 'vite-plugin-mock'
import viteSvgIcons from 'vite-plugin-svg-icons'
const setAlias = (alias: [string, string][]) => alias.map(v => {return { find: v[0], replacement: path.resolve(__dirname, v[1]) }})
const proxy = (list: [string, string][]) => {
const obj:IObject<any> = {}
list.forEach((v) => {
obj[v[0]] = {
target: v[1],
changeOrigin: true,
rewrite: (path:any) => path.replace(new RegExp(`^${v[0]}`), ''),
...(/^https:\/\//.test(v[1]) ? { secure: false } : {})
}
})
return obj
}
export default ({ command, mode }: ConfigEnv): UserConfigExport => {
const root = process.cwd()
const env = loadEnv(mode, root) as unknown as ImportMetaEnv
const prodMock = true
return {
resolve: {
alias: setAlias([
['/@', 'src'],
['/mock', 'mock'],
['/server', 'server']
])
},
server: {
proxy: env.VITE_PROXY ? proxy(JSON.parse(env.VITE_PROXY)) : {},
port: env.VITE_PORT
},
build: {
// sourcemap: true,
manifest: true,
rollupOptions: {
output: {
manualChunks: {
'element-plus': ['element-plus'],
echarts: ['echarts'],
pinyin: ['pinyin']
}
}
},
chunkSizeWarningLimit: 600
},
plugins: [
vue(),
viteMockServe({
mockPath: 'mock',
localEnabled: command === 'serve',
prodEnabled: command !== 'serve' && prodMock,
// 这样可以控制关闭mock的时候不让mock打包到最终代码内
injectCode: `
import { setupProdMockServer } from '/mock/mockProdServer';
setupProdMockServer();
`
}),
viteSvgIcons({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), 'src/icons')],
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]'
})
],
css: {
postcss: {
plugins: [
require('autoprefixer'),
require('tailwindcss/nesting'),
require('tailwindcss'),
require('postcss-simple-vars'),
require('postcss-import')
]
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/openex/element-plus-admin.git
git@gitee.com:openex/element-plus-admin.git
openex
element-plus-admin
element-plus-admin
master

搜索帮助