vite.config.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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: ['> 0.25%, not dead'],
  17. ignoreBrowserslistConfig: true,
  18. }),
  19. vue(),
  20. vueJsx(),
  21. createStyleImportPlugin({
  22. libs: [
  23. {
  24. libraryName: "vant",
  25. esModule: true,
  26. // resolveStyle: (name) => ,
  27. },
  28. ],
  29. }),
  30. ],
  31. css: {
  32. postcss: {
  33. plugins: [
  34. postCssPxToRem({
  35. rootValue: 37.5,
  36. propList: ["*"],
  37. selectorBlackList: [".norem"],
  38. }),
  39. ],
  40. },
  41. },
  42. build: {
  43. rollupOptions: {
  44. input: {
  45. index: resolve(__dirname, "index.html"),
  46. colexiu: resolve(__dirname, "colexiu.html"),
  47. orchestra: resolve(__dirname, "orchestra.html"),
  48. "report-share": resolve(__dirname, "report-share.html"),
  49. instrument: resolve(__dirname, "instrument.html"),
  50. },
  51. },
  52. },
  53. server: {
  54. cors: true,
  55. port: 3000,
  56. // https: true,
  57. proxy: {
  58. "^/gym/.*": {
  59. target: "https://mstutest.dayaedu.com",
  60. // target: "https://online.dayaedu.com",
  61. changeOrigin: true,
  62. rewrite: (path) => path.replace(/^\/gym/, ""),
  63. },
  64. "^/colexiu/.*": {
  65. target: "https://dev.colexiu.com",
  66. // target: "https://online.colexiu.com",
  67. changeOrigin: true,
  68. rewrite: (path) => path.replace(/^\/colexiu/, ""),
  69. },
  70. "^/orchestra/.*": {
  71. target: "https://test.lexiaoya.cn",
  72. changeOrigin: true,
  73. rewrite: (path) => path.replace(/^\/orchestra/, ""),
  74. },
  75. "^/instrument/.*": {
  76. target: "https://dev.kt.colexiu.com",
  77. // target: "https://test.lexiaoya.cn",
  78. changeOrigin: true,
  79. rewrite: (path) => path.replace(/^\/instrument/, ""),
  80. },
  81. },
  82. },
  83. preview:{
  84. port: 3000,
  85. host: '192.168.3.114'
  86. }
  87. });
  88. // vite.config.js