vite.config.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. port: 3000,
  14. fs: {
  15. strict: false
  16. }
  17. },
  18. plugins: [
  19. vue(),
  20. viteImagemin({
  21. gifsicle: {
  22. optimizationLevel: 7,
  23. interlaced: false
  24. },
  25. optipng: false,
  26. mozjpeg: {
  27. quality: 80
  28. },
  29. pngquant: {
  30. quality: [0.5, 0.9],
  31. speed: 1
  32. },
  33. svgo: {
  34. plugins: [
  35. {
  36. name: 'removeViewBox'
  37. },
  38. {
  39. name: 'removeEmptyAttrs',
  40. active: false
  41. }
  42. ]
  43. },
  44. webp: false
  45. }),
  46. mode === 'app'
  47. ? null
  48. : VitePWA({
  49. registerType: 'autoUpdate',
  50. manifest: {
  51. name: 'FirstCash',
  52. short_name: 'FirstCash',
  53. theme_color: '#161616',
  54. background_color: '#161616',
  55. display: 'fullscreen',
  56. icons: [
  57. {
  58. src: '/icon-192x192.png',
  59. sizes: '192x192',
  60. type: 'image/png'
  61. },
  62. {
  63. src: '/icon-256x256.png',
  64. sizes: '256x256',
  65. type: 'image/png'
  66. },
  67. {
  68. src: '/icon-384x384.png',
  69. sizes: '384x384',
  70. type: 'image/png'
  71. },
  72. {
  73. src: '/icon-512x512.png',
  74. sizes: '512x512',
  75. type: 'image/png'
  76. }
  77. ]
  78. }
  79. })
  80. ].filter(i => i != null),
  81. resolve: {
  82. alias: {
  83. '@': fileURLToPath(new URL('./src', import.meta.url))
  84. }
  85. },
  86. css: {
  87. preprocessorOptions: {
  88. less: {
  89. javascriptEnabled: true,
  90. additionalData: '@import "@/styles/common.less";'
  91. }
  92. }
  93. }
  94. }
  95. })