vite.config.js 2.7 KB

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