vite.config.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig, loadEnv } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import viteImagemin from 'vite-plugin-imagemin'
  5. import { VitePWA } from 'vite-plugin-pwa'
  6. // https://vitejs.dev/config/
  7. export default defineConfig(({ command, mode }) => {
  8. process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }
  9. return {
  10. base: process.env.VITE_BASE_URL,
  11. server: {
  12. host: '0.0.0.0'
  13. },
  14. plugins: [
  15. vue(),
  16. viteImagemin({
  17. gifsicle: {
  18. optimizationLevel: 7,
  19. interlaced: false
  20. },
  21. optipng: false,
  22. mozjpeg: {
  23. quality: 80
  24. },
  25. pngquant: {
  26. quality: [0.5, 0.9],
  27. speed: 1
  28. },
  29. svgo: {
  30. plugins: [
  31. {
  32. name: 'removeViewBox'
  33. },
  34. {
  35. name: 'removeEmptyAttrs',
  36. active: false
  37. }
  38. ]
  39. },
  40. webp: false
  41. }),
  42. VitePWA({
  43. registerType: 'autoUpdate',
  44. manifest: {
  45. name: 'FirstCash',
  46. short_name: 'FirstCash',
  47. theme_color: '#161616',
  48. background_color: '#161616',
  49. display: 'fullscreen',
  50. icons: [
  51. {
  52. src: '/icon-192x192.png',
  53. sizes: '192x192',
  54. type: 'image/png'
  55. },
  56. {
  57. src: '/icon-256x256.png',
  58. sizes: '256x256',
  59. type: 'image/png'
  60. },
  61. {
  62. src: '/icon-384x384.png',
  63. sizes: '384x384',
  64. type: 'image/png'
  65. },
  66. {
  67. src: '/icon-512x512.png',
  68. sizes: '512x512',
  69. type: 'image/png'
  70. }
  71. ]
  72. }
  73. })
  74. ],
  75. resolve: {
  76. alias: {
  77. '@': fileURLToPath(new URL('./src', import.meta.url))
  78. }
  79. },
  80. css: {
  81. preprocessorOptions: {
  82. less: {
  83. javascriptEnabled: true,
  84. additionalData: '@import "@/styles/common.less";'
  85. }
  86. }
  87. }
  88. }
  89. })