vite.config.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. const path = require("path");
  2. import { defineConfig } from "vite";
  3. import vue from "@vitejs/plugin-vue";
  4. import { VitePWA } from "vite-plugin-pwa";
  5. import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
  6. const vueJsx = require("@vitejs/plugin-vue-jsx");
  7. const legacy = require("@vitejs/plugin-legacy");
  8. const proxyUrl = "https://test.dayaedu.com/"; // test 环境
  9. // const proxyUrl = "https://online.dayaedu.com/"; // test 环境
  10. // https://vitejs.dev/config/
  11. export default defineConfig({
  12. base: "./",
  13. // '/src': resolve(__dirname, './src')
  14. resolve: {
  15. alias: {
  16. // '/src': path.resolve(__dirname, './src'),
  17. },
  18. },
  19. css: {
  20. preprocessorOptions: {
  21. // less: {
  22. // lessOptions: {
  23. // modifyVars: {
  24. // '@blue': '#01A79E',
  25. // '@nav-bar-icon-color': '#01A79E'
  26. // }
  27. // }
  28. // }
  29. },
  30. },
  31. plugins: [
  32. createSvgIconsPlugin({
  33. // 指定需要缓存的图标文件夹
  34. iconDirs: [path.resolve(process.cwd(), "src/icons")],
  35. // 指定symbolId格式
  36. symbolId: "icon-[dir]-[name]",
  37. customDomId: "__svg__icons__dom__",
  38. }),
  39. vue(),
  40. vueJsx(),
  41. legacy({
  42. targets: ["> 0.25%, not dead"],
  43. ignoreBrowserslistConfig: true,
  44. }),
  45. // VitePWA({
  46. // injectRegister: "auto",
  47. // workbox: {
  48. // cleanupOutdatedCaches: true
  49. // },
  50. // base: './',
  51. // manifest: {
  52. // name: '管乐迷',
  53. // short_name: '管乐迷',
  54. // theme_color: '#01C1B5',
  55. // icons: [
  56. // {
  57. // src: './pwa-192x192.png',
  58. // sizes: '192x192',
  59. // type: 'image/png',
  60. // },
  61. // {
  62. // src: './pwa-512x512.png',
  63. // sizes: '512x512',
  64. // type: 'image/png',
  65. // },
  66. // ],
  67. // },
  68. // })
  69. ],
  70. server: {
  71. host: "0.0.0.0",
  72. cors: true,
  73. proxy: {
  74. "/api-im": {
  75. target: proxyUrl,
  76. changeOrigin: true,
  77. },
  78. "/api-web": {
  79. target: proxyUrl,
  80. changeOrigin: true,
  81. },
  82. "/api-auth": {
  83. target: proxyUrl,
  84. changeOrigin: true,
  85. },
  86. "/api-teacher": {
  87. target: proxyUrl,
  88. changeOrigin: true,
  89. },
  90. },
  91. },
  92. });