vite.config.js 3.1 KB

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