金币系统前端
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

1 month ago
4 months ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
4 months ago
1 month ago
  1. import { defineConfig, loadEnv } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import { lazyImport, VxeResolver } from 'vite-plugin-lazy-import'
  4. import legacy from '@vitejs/plugin-legacy'
  5. import path from 'path'
  6. import { visualizer } from 'rollup-plugin-visualizer'
  7. // https://vite.dev/config/
  8. export default defineConfig(({ mode }) => {
  9. const env = loadEnv(mode, process.cwd())
  10. console.log('当前环境:', mode)
  11. console.log('当前环境变量:', env)
  12. return {
  13. esbuild: {
  14. supported: {
  15. bigint: true
  16. },
  17. treeShaking: true
  18. },
  19. plugins: [
  20. vue(),
  21. visualizer({
  22. open: true, // 打包完成后自动展示
  23. gzipSize: true, // 显示gzip压缩后的大小
  24. brotliSize: true // 显示brotli压缩后的大小
  25. }),
  26. legacy({
  27. targets: ['defaults', 'not IE 11', 'chrome >=73'],
  28. modernPolyfills: true
  29. }),
  30. lazyImport({
  31. resolvers: [
  32. VxeResolver({
  33. libraryName: 'vxe-table'
  34. }),
  35. VxeResolver({
  36. libraryName: 'vxe-pc-ui'
  37. })
  38. ]
  39. })
  40. ],
  41. resolve: {
  42. alias: {
  43. '@': path.resolve(__dirname, './src')
  44. }
  45. },
  46. base: process.env.NODE_ENV === 'production' ? './' : '/',
  47. build: {
  48. sourcemap: false, // 关闭 sourcemap
  49. minify: 'terser',
  50. terserOptions: {
  51. compress: {
  52. drop_console: true, // 生产环境去除console
  53. drop_debugger: true // 生产环境去除 debugger
  54. }
  55. },
  56. rollupOptions: {
  57. output: {
  58. manualChunks: {
  59. echarts: ['echarts'],
  60. xlsx: ['xlsx'],
  61. lodash: ['lodash'],
  62. vue: ['vue', 'vue-router', 'pinia'],
  63. elementPlus: ['element-plus']
  64. }
  65. }
  66. }
  67. }
  68. }
  69. })