vite.config.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. export default defineConfig((mode) => {
  6. return {
  7. // Project plugins
  8. plugins: [
  9. vue(),
  10. viteCompression({
  11. verbose: true,
  12. disable: false,
  13. threshold: 1025,
  14. algorithm: 'gzip',
  15. ext: '.gz',
  16. }),
  17. ],
  18. // Base configuration
  19. base: './',
  20. publicDir: 'public',
  21. resolve: {
  22. alias: {
  23. '@': path.resolve(__dirname, 'src'),
  24. },
  25. },
  26. css: {
  27. preprocessorOptions: {
  28. less: {
  29. modifyVars: {
  30. '@border-color-base': '#dce3e8',
  31. },
  32. javascriptEnabled: true,
  33. },
  34. },
  35. },
  36. build: {
  37. outDir: 'dist',
  38. assetsDir: 'assets',
  39. assetsInlineLimit: 4096,
  40. cssCodeSplit: true,
  41. brotliSize: false,
  42. sourcemap: false,
  43. minify: 'terser',
  44. terserOptions: {
  45. compress: {
  46. // Remove console and debugger in production
  47. drop_console: false,
  48. drop_debugger: true,
  49. },
  50. },
  51. },
  52. };
  53. });