vite.config.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { defineConfig } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import vueJsx from "@vitejs/plugin-vue-jsx";
  4. import legacy from "@vitejs/plugin-legacy";
  5. import { resolve } from "path";
  6. import postCssPxToRem from "postcss-pxtorem";
  7. import { visualizer } from 'rollup-plugin-visualizer';
  8. // https://vitejs.dev/config/
  9. export default defineConfig({
  10. base: "./",
  11. resolve: {},
  12. // assetsInclude: ['**/*.html'],
  13. plugins: [
  14. // mkcert(), // 本地https
  15. legacy({
  16. targets: ['Chrome 63'],
  17. additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
  18. modernPolyfills: true
  19. }),
  20. vue(),
  21. vueJsx(),
  22. // visualizer({ open: true }), // 自动开启分析页面
  23. ],
  24. css: {
  25. postcss: {
  26. plugins: [
  27. postCssPxToRem({
  28. rootValue: 37.5,
  29. propList: ["*"],
  30. selectorBlackList: [".norem"],
  31. }),
  32. ],
  33. },
  34. },
  35. build: {
  36. rollupOptions: {
  37. input: {
  38. gym: resolve(__dirname, "index.html"),
  39. colexiu: resolve(__dirname, "colexiu.html"),
  40. orchestra: resolve(__dirname, "orchestra.html"),
  41. "report-share": resolve(__dirname, "report-share.html"),
  42. instrument: resolve(__dirname, "instrument.html"),
  43. },
  44. },
  45. },
  46. server: {
  47. cors: true,
  48. port: 3000,
  49. // https: true,
  50. proxy: {
  51. "^/gym/.*": {
  52. target: "https://mstutest.dayaedu.com",
  53. // target: "https://online.dayaedu.com",
  54. changeOrigin: true,
  55. rewrite: (path) => path.replace(/^\/gym/, ""),
  56. },
  57. "^/colexiu/.*": {
  58. target: "https://dev.colexiu.com",
  59. // target: "https://online.colexiu.com",
  60. changeOrigin: true,
  61. rewrite: (path) => path.replace(/^\/colexiu/, ""),
  62. },
  63. "^/orchestra/.*": {
  64. target: "https://test.lexiaoya.cn",
  65. changeOrigin: true,
  66. rewrite: (path) => path.replace(/^\/orchestra/, ""),
  67. },
  68. "^/instrument/.*": {
  69. // target: "https://kt.colexiu.com",
  70. // target: "https://test.lexiaoya.cn",
  71. // target: "https://dev.kt.colexiu.com",
  72. target: "https://test.resource.colexiu.com", // 内容平台开发环境,内容平台开发,需在url链接上加上isCbs=true
  73. // target: "https://dev.resource.colexiu.com",
  74. // target: "https://test.kt.colexiu.com",
  75. // target: "https://mec.colexiu.com",
  76. changeOrigin: true,
  77. rewrite: (path) => path.replace(/^\/instrument/, ""),
  78. },
  79. },
  80. },
  81. preview:{
  82. port: 3000,
  83. host: '192.168.3.114'
  84. }
  85. });
  86. // vite.config.js