vite.config.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. const { resolve } = require('path')
  2. import { defineConfig } from 'vite'
  3. import vue from "@vitejs/plugin-vue";
  4. import { VitePWA } from 'vite-plugin-pwa'
  5. const vueJsx = require('@vitejs/plugin-vue-jsx')
  6. const legacy = require('@vitejs/plugin-legacy')
  7. const proxyUrl = "https://test.dayaedu.com/"; // test 环境
  8. // https://vitejs.dev/config/
  9. export default defineConfig({
  10. base: "./",
  11. // '/src': resolve(__dirname, './src')
  12. resolve: {
  13. alias: {
  14. // '/src': resolve(__dirname, './src'),
  15. }
  16. },
  17. css: {
  18. preprocessorOptions: {
  19. less: {
  20. // lessOptions: {
  21. // modifyVars: {
  22. // '@blue': '#14928A',
  23. // '@nav-bar-icon-color': '#14928A'
  24. // }
  25. // }
  26. }
  27. }
  28. },
  29. plugins: [
  30. vue(),
  31. vueJsx(),
  32. legacy({
  33. targets: ["> 0.25%, not dead"],
  34. ignoreBrowserslistConfig: true,
  35. }),
  36. VitePWA({
  37. injectRegister: "auto",
  38. workbox: {
  39. cleanupOutdatedCaches: true
  40. },
  41. base: './',
  42. manifest: {
  43. name: '管乐迷',
  44. short_name: '管乐迷',
  45. theme_color: '#01C1B5',
  46. icons: [
  47. {
  48. src: './pwa-192x192.png',
  49. sizes: '192x192',
  50. type: 'image/png',
  51. },
  52. {
  53. src: './pwa-512x512.png',
  54. sizes: '512x512',
  55. type: 'image/png',
  56. },
  57. ],
  58. },
  59. })
  60. ],
  61. server: {
  62. cors: true,
  63. proxy: {
  64. '/api-web': {
  65. target: proxyUrl,
  66. changeOrigin: true
  67. },
  68. '/api-auth': {
  69. target: proxyUrl,
  70. changeOrigin: true
  71. }
  72. }
  73. }
  74. });