vue.config.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. let proxy = {
  2. "/api": {
  3. target: "https://192.168.10.39:8878",
  4. changeOrigin: true,
  5. },
  6. };
  7. // const stu = [
  8. // "/api/ecs_oe",
  9. // "/api/ecs_oe_student/",
  10. // "/api/sys_param",
  11. // "/api/exam_record",
  12. // "/api/exam_control",
  13. // "/api/exam_question",
  14. // "/api/exam_score",
  15. // "/api/practice_course",
  16. // "/api/practice_detail",
  17. // "/api/practice_record",
  18. // "/api/exam_captures",
  19. // "/api/face_capture",
  20. // "/api/face_verify",
  21. // "/api/offline_exam"
  22. // ];
  23. // for (const s of stu) {
  24. // proxy[s] = {
  25. // target: "http://ecs-dev.qmth.com.cn:8003", // 陈恳
  26. // changeOrigin: true
  27. // };
  28. // }
  29. // const mock = [{ source: "/api/mock/exam_question", dest: "/examQuestions" }];
  30. // for (const m of mock) {
  31. // proxy[m.source] = {
  32. // target: "http://localhost:3000/",
  33. // changeOrigin: true,
  34. // pathRewrite: {
  35. // ".*": m.dest
  36. // }
  37. // };
  38. // }
  39. var webpack = require("webpack");
  40. // const plugins = [];
  41. // Ignore all locale files of moment.js
  42. // TODO: use webpack stats to check if iview locale matters
  43. // plugins.push();
  44. // if (process.env.NODE_ENV === "production") {
  45. // plugins.push("transform-remove-console");
  46. // }
  47. module.exports = {
  48. lintOnSave: process.env.NODE_ENV !== "production" ? true : "error",
  49. devServer: {
  50. proxy,
  51. },
  52. chainWebpack: config => {
  53. // iview Loader
  54. config.module
  55. .rule("vue")
  56. .test(/\.vue$/)
  57. .use("iview-loader")
  58. .loader("iview-loader")
  59. .options({
  60. prefix: true,
  61. })
  62. .end();
  63. },
  64. configureWebpack: {
  65. devtool: "source-map",
  66. plugins: [new webpack.IgnorePlugin(/^\.\/locale$/, /moment|iview$/)],
  67. },
  68. pwa: {
  69. workboxPluginMode: "GenerateSW",
  70. workboxOptions: {
  71. importWorkboxFrom: "local",
  72. // navigateFallback: "index.html",
  73. skipWaiting: true,
  74. clientsClaim: true,
  75. runtimeCaching: [
  76. {
  77. // 背景图如果要换,就改地址,减少网络消耗
  78. urlPattern: new RegExp(
  79. "^https://cdn.qmth.com.cn/ui/ecs-client-bg.jpg!/progressive/true"
  80. ),
  81. handler: "cacheFirst",
  82. options: {
  83. cacheableResponse: {
  84. statuses: [0, 200],
  85. },
  86. },
  87. },
  88. {
  89. // Match any same-origin request that contains 'api'.
  90. // 产品名称有可能每分钟都更新
  91. urlPattern: /\/api\/ecs_core\/org\/propertyNoSession\/OE_STUDENT_SYS_NAME\?domainName=/,
  92. handler: "cacheFirst",
  93. options: {
  94. cacheableResponse: {
  95. statuses: [0, 200],
  96. },
  97. cacheName: "sys-name-cache",
  98. expiration: {
  99. maxAgeSeconds: 60,
  100. },
  101. },
  102. },
  103. {
  104. // Match any same-origin request that contains 'api'.
  105. // logo 地址会变
  106. urlPattern: new RegExp(
  107. "^https://ecs-test-static.qmth.com.cn/org_logo/.*/.*"
  108. ),
  109. handler: "cacheFirst",
  110. options: {
  111. cacheableResponse: {
  112. statuses: [0, 200],
  113. },
  114. },
  115. },
  116. {
  117. urlPattern: /\/models\/.*\/.*\.json/,
  118. handler: "cacheFirst",
  119. options: {
  120. cacheableResponse: {
  121. statuses: [0, 200],
  122. },
  123. },
  124. },
  125. {
  126. // Match any same-origin request that contains 'api'.
  127. // 客观分10分钟更新一次
  128. urlPattern: /\/api\/ecs_oe_student\/examScore\/queryObjectiveScoreList\?examStudentId=/,
  129. handler: "cacheFirst",
  130. options: {
  131. cacheableResponse: {
  132. statuses: [0, 200],
  133. },
  134. cacheName: "objective-score-list-cache",
  135. expiration: {
  136. maxAgeSeconds: 10 * 60,
  137. },
  138. },
  139. },
  140. {
  141. // 站内消息3分钟获取一次
  142. urlPattern: /\/api\/ecs_exam_work\/notice\/getUserNoticeList\?/,
  143. handler: "cacheFirst",
  144. options: {
  145. cacheableResponse: {
  146. statuses: [0, 200],
  147. },
  148. cacheName: "site-messages-list-cache",
  149. expiration: {
  150. maxAgeSeconds: 3 * 60,
  151. },
  152. },
  153. },
  154. ],
  155. },
  156. },
  157. };