vite.config.ts 2.1 KB

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