vite.config.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import vue from '@vitejs/plugin-vue'
  2. import { defineConfig } from 'vite'
  3. import viteCompression from 'vite-plugin-compression'
  4. import path from 'path'
  5. // https://vitejs.dev/config/
  6. export default defineConfig(({ command, mode }) => {
  7. return {
  8. // 项目插件
  9. plugins: [
  10. vue(),
  11. viteCompression({
  12. verbose: true,
  13. disable: false,
  14. threshold: 1025,
  15. algorithm: 'gzip',
  16. ext: '.gz',
  17. }),
  18. ],
  19. // 基础配置
  20. base: './',
  21. publicDir: 'public',
  22. resolve: {
  23. alias: {
  24. '@': path.resolve(__dirname, 'src'),
  25. },
  26. },
  27. css: {
  28. preprocessorOptions: {
  29. less: {
  30. modifyVars: {
  31. '@border-color-base': '#dce3e8',
  32. },
  33. javascriptEnabled: true,
  34. },
  35. },
  36. },
  37. build: {
  38. outDir: 'dist',
  39. assetsDir: 'assets',
  40. assetsInlineLimit: 4096,
  41. cssCodeSplit: true,
  42. brotliSize: false,
  43. sourcemap: false,
  44. minify: 'terser',
  45. terserOptions: {
  46. compress: {
  47. // 生产环境去除console及debug
  48. drop_console: false,
  49. drop_debugger: true,
  50. },
  51. },
  52. },
  53. }
  54. })