vite.config.js 1.2 KB

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