NetAdmin/src/frontend/admin/vite.config.js
tk d26e4c77cc feat: 基础模块
注册登录
用户管理
角色管理
部门管理
消息管理
接口管理
菜单管理
字典管理
缓存管理
请求日志
系统设置
版本信息
代码生成
2023-11-17 19:12:47 +08:00

79 lines
2.2 KiB
JavaScript

import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
base: './',
plugins: [vue()],
resolve: {
alias: {
// 设置路径
'~': path.resolve(__dirname, './'),
// 设置别名
'@': path.resolve(__dirname, './src'),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
},
// vite 相关配置
server: {
port: 5020,
host: true,
open: false,
proxy: {
'/api': {
target: 'http://localhost:5010/api',
changeOrigin: true,
rewrite: (p) => p.replace(/^\/api/, ''),
},
},
},
css: {
postcss: {
plugins: [
{
postcssPlugin: 'internal:charset-removal',
AtRule: {
charset: (atRule) => {
if (atRule.name === 'charset') {
atRule.remove()
}
},
},
},
],
},
},
build: {
emptyOutDir: true,
outDir: '../../../dist/frontend/admin',
assetsDir: 'assets',
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
rollupOptions: {
// 拆包
output: {
chunkFileNames: 'js/[name]-[hash].js',
entryFileNames: 'js/[name]-[hash].js',
assetFileNames: '[ext]/[name]-[hash].[ext]',
manualChunks(id) {
if (id.includes('node_modules')) {
return id.split('/node_modules/').pop()?.split('/')[0]
}
},
// 第三方库拆包
// manualChunks: {
// xgplayer: ['xgplayer'],
// xlsx: ['xlsx'],
// tinymce: ['tinymce'],
// elicons: ['@element-plus/icons-vue']
// }
},
},
},
})