vite.config.ts 1.7 KB

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