vite.config.ts 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 { visualizer } from "rollup-plugin-visualizer";
  8. import viteCompression from "vite-plugin-compression";
  9. // https://vitejs.dev/config/
  10. export default defineConfig({
  11. base: "./",
  12. resolve: {},
  13. // assetsInclude: ['**/*.html'],
  14. plugins: [
  15. // mkcert(), // 本地https
  16. legacy({
  17. targets: ["Chrome 63"],
  18. additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
  19. modernPolyfills: true,
  20. }),
  21. vue(),
  22. vueJsx(),
  23. visualizer({ open: true }), // 自动开启分析页面
  24. ],
  25. css: {
  26. postcss: {
  27. plugins: [
  28. postCssPxToRem({
  29. rootValue: 37.5,
  30. propList: ["*"],
  31. selectorBlackList: [".norem"],
  32. }),
  33. ],
  34. },
  35. },
  36. build: {
  37. rollupOptions: {
  38. input: {
  39. gym: resolve(__dirname, "index.html"),
  40. colexiu: resolve(__dirname, "colexiu.html"),
  41. orchestra: resolve(__dirname, "orchestra.html"),
  42. "report-share": resolve(__dirname, "report-share.html"),
  43. instrument: resolve(__dirname, "instrument.html"),
  44. },
  45. output: {
  46. chunkFileNames: "js/[name]-[hash].js", // 引入文件名的名称
  47. entryFileNames: "js/[name]-[hash].js", // 包的入口文件名称
  48. assetFileNames: "[ext]/[name]-[hash].[ext]", // 资源文件像 字体,图片等
  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://kt.colexiu.com",
  76. // target: "https://test.lexiaoya.cn",
  77. // target: "https://kt.colexiu.com",
  78. target: "https://dev.resource.colexiu.com", // 内容平台开发环境,内容平台开发,需在url链接上加上isCbs=true
  79. // target: "https://test.kt.colexiu.com",
  80. // target: "https://mec.colexiu.com",
  81. changeOrigin: true,
  82. rewrite: (path) => path.replace(/^\/instrument/, ""),
  83. },
  84. },
  85. },
  86. preview: {
  87. port: 3000,
  88. host: "192.168.3.114",
  89. },
  90. });
  91. // vite.config.js