vite.config.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import { defineConfig, loadEnv } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import { resolve } from "path";
  4. // vue setup 的糖语法
  5. import VueSetupExtend from "vite-plugin-vue-setup-extend";
  6. // 不用导入 vue 的 import 了
  7. import AutoImport from "unplugin-auto-import/vite";
  8. import Icons from "unplugin-icons/vite";
  9. import vueJsx from "@vitejs/plugin-vue-jsx";
  10. import { createHtmlPlugin } from "vite-plugin-html";
  11. import pkg from "./package.json";
  12. import { codeInspectorPlugin } from "code-inspector-plugin";
  13. const pathResolve = dir => {
  14. return resolve(__dirname, ".", dir);
  15. };
  16. const alias = {
  17. "@": pathResolve("src"),
  18. };
  19. export default defineConfig(({ mode }) => {
  20. const ENV = loadEnv(mode, process.cwd());
  21. const GLOB_CONFIG_FILE_NAME = "_app.config.js";
  22. const isBuild = mode === "production";
  23. const getAppConfigSrc = () => {
  24. return `/${GLOB_CONFIG_FILE_NAME}?v=${pkg.version}-${new Date().getTime()}`;
  25. };
  26. return {
  27. define: {
  28. __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "true",
  29. },
  30. esbuild: {
  31. jsxFactory: "h",
  32. jsxFragment: "Fragment",
  33. },
  34. externals: {
  35. BMap: "BMap",
  36. BMapLib: "BMapLib",
  37. },
  38. resolve: {
  39. alias: {
  40. ...alias,
  41. "vxe-pc-ui": pathResolve("node_modules/vxe-pc-ui"),
  42. "vxe-table": pathResolve("node_modules/vxe-table"),
  43. },
  44. // alias,
  45. extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
  46. },
  47. plugins: [
  48. codeInspectorPlugin({
  49. bundler: "vite",
  50. hideConsole: true,
  51. }),
  52. Icons({
  53. autoInstall: true,
  54. compiler: "vue3",
  55. }),
  56. VueSetupExtend({ name: false }),
  57. vue(),
  58. vueJsx(),
  59. AutoImport({
  60. dts: "src/auto-imports.d.ts",
  61. imports: ["vue"],
  62. }),
  63. createHtmlPlugin({
  64. minify: isBuild,
  65. inject: {
  66. data: {
  67. title: "",
  68. },
  69. // Embed the generated app.config.js file
  70. tags: isBuild
  71. ? [
  72. {
  73. tag: "script",
  74. attrs: {
  75. src: getAppConfigSrc(),
  76. },
  77. },
  78. ]
  79. : [],
  80. },
  81. }),
  82. ],
  83. server: {
  84. host: "0.0.0.0",
  85. port: 3000,
  86. proxy: {
  87. "/fuYou": {
  88. //这里配置运行时服务地址
  89. // http://58.33.165.250:20011/mchis-controller/services/Mchis.MchisHttpSoap11Endpoin
  90. // target: "http://58.33.165.250:20011",
  91. target: "http://192.168.100.140:18080",
  92. secure: false, //如果运行时服务是https,此处配置为true
  93. changeOrigin: true, //支持跨域调用,这里配置为true
  94. rewrite: path => path.replace(/^\/fuYou/, ""),
  95. },
  96. "/emr": {
  97. //这里配置运行时服务地址
  98. target: "http://130.150.161.69:8001/emr",
  99. secure: false, //如果运行时服务是https,此处配置为true
  100. changeOrigin: true, //支持跨域调用,这里配置为true
  101. rewrite: path => path.replace(/^\/emr/, ""),
  102. },
  103. "/doctorSignatureImage": {
  104. target: "http://172.16.32.167:8077",
  105. secure: false, //如果运行时服务是https,此处配置为true
  106. changeOrigin: true, //支持跨域调用,这里配置为true
  107. },
  108. "/thyyarchive": {
  109. target: "http://172.16.32.197:9202/",
  110. secure: false,
  111. changeOrigin: true,
  112. rewrite: path => path.replace(/^\/thyyarchive/, ""),
  113. },
  114. },
  115. },
  116. build: {
  117. chunkSizeWarningLimit: 1000,
  118. outDir: "release/dist",
  119. // rollupOptions: {
  120. // output: {
  121. // manualChunks: {
  122. // // 将 vxe 相关库打包在一起
  123. // 'vxe-ui': ['vxe-pc-ui', 'vxe-table', 'vxe-table-plugin-export-xlsx']
  124. // }
  125. // }
  126. // }
  127. // 优化打包把第三方的东西每次打包时都不重复
  128. // rollupOptions: {
  129. // output: {
  130. // manualChunks(id) {
  131. // if (id.includes("node_modules")) {
  132. // return id
  133. // .toString()
  134. // .split("node_modules/")[1]
  135. // .split("/")[0]
  136. // .toString();
  137. // }
  138. // return null;
  139. // },
  140. // },
  141. // },
  142. },
  143. };
  144. });