vite.config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. // https://vitejs.dev/config/
  6. export default defineConfig(({ command, mode }) => {
  7. return {
  8. base: mode === 'production' ? '/h5/' : '/',
  9. server: {
  10. host: '0.0.0.0'
  11. },
  12. plugins: [
  13. vue(),
  14. viteImagemin({
  15. gifsicle: {
  16. optimizationLevel: 7,
  17. interlaced: false
  18. },
  19. optipng: false,
  20. mozjpeg: {
  21. quality: 20
  22. },
  23. pngquant: {
  24. quality: [0.5, 0.9],
  25. speed: 1
  26. },
  27. svgo: {
  28. plugins: [
  29. {
  30. name: 'removeViewBox'
  31. },
  32. {
  33. name: 'removeEmptyAttrs',
  34. active: false
  35. }
  36. ]
  37. },
  38. webp: false
  39. })
  40. ],
  41. resolve: {
  42. alias: {
  43. '@': fileURLToPath(new URL('./src', import.meta.url))
  44. }
  45. },
  46. css: {
  47. preprocessorOptions: {
  48. less: {
  49. javascriptEnabled: true,
  50. additionalData: '@import "@/styles/common.less";'
  51. }
  52. }
  53. }
  54. }
  55. })