vite.config.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. "report-share": resolve(__dirname, "report-share.html"),
  46. },
  47. },
  48. },
  49. server: {
  50. cors: true,
  51. port: 3000,
  52. proxy: {
  53. "^/gym/.*": {
  54. target: "https://mstutest.dayaedu.com",
  55. // target: "https://online.dayaedu.com",
  56. changeOrigin: true,
  57. rewrite: (path) => path.replace(/^\/gym/, ""),
  58. },
  59. "^/colexiu/.*": {
  60. target: "https://online.colexiu.com",
  61. changeOrigin: true,
  62. rewrite: (path) => path.replace(/^\/colexiu/, ""),
  63. },
  64. "^/orchestra/.*": {
  65. target: "https://test.lexiaoya.cn",
  66. changeOrigin: true,
  67. rewrite: (path) => path.replace(/^\/orchestra/, ""),
  68. },
  69. },
  70. },
  71. preview:{
  72. port: 3010
  73. }
  74. });
  75. // vite.config.js