You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.8 KiB
70 lines
1.8 KiB
import { defineConfig, loadEnv } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import { lazyImport, VxeResolver } from 'vite-plugin-lazy-import'
|
|
import legacy from '@vitejs/plugin-legacy'
|
|
import path from 'path'
|
|
import { visualizer } from 'rollup-plugin-visualizer'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd())
|
|
console.log('当前环境:', mode)
|
|
console.log('当前环境变量:', env)
|
|
return {
|
|
esbuild: {
|
|
supported: {
|
|
bigint: true
|
|
},
|
|
treeShaking: true
|
|
},
|
|
plugins: [
|
|
vue(),
|
|
visualizer({
|
|
open: true, // 打包完成后自动展示
|
|
gzipSize: true, // 显示gzip压缩后的大小
|
|
brotliSize: true // 显示brotli压缩后的大小
|
|
}),
|
|
legacy({
|
|
targets: ['defaults', 'not IE 11', 'chrome >=73'],
|
|
modernPolyfills: true
|
|
}),
|
|
lazyImport({
|
|
resolvers: [
|
|
VxeResolver({
|
|
libraryName: 'vxe-table'
|
|
}),
|
|
VxeResolver({
|
|
libraryName: 'vxe-pc-ui'
|
|
})
|
|
]
|
|
})
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src')
|
|
}
|
|
},
|
|
base: process.env.NODE_ENV === 'production' ? './' : '/',
|
|
build: {
|
|
sourcemap: false, // 关闭 sourcemap
|
|
minify: 'terser',
|
|
terserOptions: {
|
|
compress: {
|
|
drop_console: true, // 生产环境去除console
|
|
drop_debugger: true // 生产环境去除 debugger
|
|
}
|
|
},
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
echarts: ['echarts'],
|
|
xlsx: ['xlsx'],
|
|
lodash: ['lodash'],
|
|
vue: ['vue', 'vue-router', 'pinia'],
|
|
elementPlus: ['element-plus']
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|