vite.config.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 = "http://dev.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. cors: true,
  72. proxy: {
  73. '/api-web': {
  74. target: proxyUrl,
  75. changeOrigin: true
  76. },
  77. '/api-auth': {
  78. target: proxyUrl,
  79. changeOrigin: true
  80. },
  81. '/api-teacher': {
  82. target: proxyUrl,
  83. changeOrigin: true
  84. }
  85. }
  86. }
  87. });