vite.config.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. // https://vitejs.dev/config/
  10. export default defineConfig({
  11. base: "./",
  12. // '/src': resolve(__dirname, './src')
  13. resolve: {
  14. alias: {
  15. // '/src': resolve(__dirname, './src'),
  16. }
  17. },
  18. css: {
  19. preprocessorOptions: {
  20. less: {
  21. // lessOptions: {
  22. // modifyVars: {
  23. // '@blue': '#14928A',
  24. // '@nav-bar-icon-color': '#14928A'
  25. // }
  26. // }
  27. }
  28. }
  29. },
  30. plugins: [
  31. createSvgIconsPlugin({
  32. // 指定需要缓存的图标文件夹
  33. iconDirs: [path.resolve(process.cwd(), 'src/icons')],
  34. // 指定symbolId格式
  35. symbolId: 'icon-[dir]-[name]',
  36. customDomId: '__svg__icons__dom__',
  37. }),
  38. vue(),
  39. vueJsx(),
  40. legacy({
  41. targets: ["> 0.25%, not dead"],
  42. ignoreBrowserslistConfig: true,
  43. }),
  44. VitePWA({
  45. injectRegister: "auto",
  46. workbox: {
  47. cleanupOutdatedCaches: true
  48. },
  49. base: './',
  50. manifest: {
  51. name: '管乐迷',
  52. short_name: '管乐迷',
  53. theme_color: '#01C1B5',
  54. icons: [
  55. {
  56. src: './pwa-192x192.png',
  57. sizes: '192x192',
  58. type: 'image/png',
  59. },
  60. {
  61. src: './pwa-512x512.png',
  62. sizes: '512x512',
  63. type: 'image/png',
  64. },
  65. ],
  66. },
  67. })
  68. ],
  69. server: {
  70. cors: true,
  71. proxy: {
  72. '/api-web': {
  73. target: proxyUrl,
  74. changeOrigin: true
  75. },
  76. '/api-auth': {
  77. target: proxyUrl,
  78. changeOrigin: true
  79. }
  80. }
  81. }
  82. });