vite.config.ts 2.0 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 { createStyleImportPlugin } from "vite-plugin-style-import";
  8. import mkcert from "vite-plugin-mkcert";
  9. // https://vitejs.dev/config/
  10. export default defineConfig({
  11. base: "./",
  12. resolve: {},
  13. plugins: [
  14. mkcert(), // 本地https
  15. legacy({
  16. targets: 'last 2 versions and not dead, > 0.3%, Firefox ESR'
  17. }),
  18. vue(),
  19. vueJsx(),
  20. createStyleImportPlugin({
  21. libs: [
  22. {
  23. libraryName: "vant",
  24. esModule: true,
  25. // resolveStyle: (name) => ,
  26. },
  27. ],
  28. }),
  29. ],
  30. css: {
  31. postcss: {
  32. plugins: [
  33. postCssPxToRem({
  34. rootValue: 37.5,
  35. propList: ["*"],
  36. selectorBlackList: [".norem"],
  37. }),
  38. ],
  39. },
  40. },
  41. build: {
  42. rollupOptions: {
  43. input: {
  44. index: resolve(__dirname, "index.html"),
  45. colexiu: resolve(__dirname, "colexiu.html"),
  46. orchestra: resolve(__dirname, "orchestra.html"),
  47. "report-share": resolve(__dirname, "report-share.html"),
  48. instrument: resolve(__dirname, "instrument.html"),
  49. },
  50. },
  51. },
  52. server: {
  53. cors: true,
  54. port: 3000,
  55. // https: true,
  56. proxy: {
  57. "^/gym/.*": {
  58. target: "https://mstutest.dayaedu.com",
  59. // target: "https://online.dayaedu.com",
  60. changeOrigin: true,
  61. rewrite: (path) => path.replace(/^\/gym/, ""),
  62. },
  63. "^/colexiu/.*": {
  64. target: "https://dev.colexiu.com",
  65. // target: "https://online.colexiu.com",
  66. changeOrigin: true,
  67. rewrite: (path) => path.replace(/^\/colexiu/, ""),
  68. },
  69. "^/orchestra/.*": {
  70. target: "https://test.lexiaoya.cn",
  71. changeOrigin: true,
  72. rewrite: (path) => path.replace(/^\/orchestra/, ""),
  73. },
  74. "^/instrument/.*": {
  75. // target: "https://dev.kt.colexiu.com",
  76. target: "https://kt.colexiu.com",
  77. changeOrigin: true,
  78. rewrite: (path) => path.replace(/^\/instrument/, ""),
  79. },
  80. },
  81. },
  82. preview:{
  83. port: 3010,
  84. }
  85. });
  86. // vite.config.js