vite.config.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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://dev.resource.colexiu.com",
  72. // target: "https://test.kt.colexiu.com",
  73. // target: "https://mec.colexiu.com",
  74. changeOrigin: true,
  75. rewrite: (path) => path.replace(/^\/instrument/, ""),
  76. },
  77. },
  78. },
  79. preview:{
  80. port: 3000,
  81. host: '192.168.3.114'
  82. }
  83. });
  84. // vite.config.js