vite.config.ts 1.6 KB

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