let proxy = { "/api": { target: "https://192.168.10.39:8878", changeOrigin: true, }, }; // const stu = [ // "/api/ecs_oe", // "/api/ecs_oe_student/", // "/api/sys_param", // "/api/exam_record", // "/api/exam_control", // "/api/exam_question", // "/api/exam_score", // "/api/practice_course", // "/api/practice_detail", // "/api/practice_record", // "/api/exam_captures", // "/api/face_capture", // "/api/face_verify", // "/api/offline_exam" // ]; // for (const s of stu) { // proxy[s] = { // target: "http://ecs-dev.qmth.com.cn:8003", // 陈恳 // changeOrigin: true // }; // } // const mock = [{ source: "/api/mock/exam_question", dest: "/examQuestions" }]; // for (const m of mock) { // proxy[m.source] = { // target: "http://localhost:3000/", // changeOrigin: true, // pathRewrite: { // ".*": m.dest // } // }; // } var webpack = require("webpack"); // const plugins = []; // Ignore all locale files of moment.js // TODO: use webpack stats to check if iview locale matters // plugins.push(); // if (process.env.NODE_ENV === "production") { // plugins.push("transform-remove-console"); // } module.exports = { lintOnSave: process.env.NODE_ENV !== "production" ? true : "error", devServer: { proxy, }, chainWebpack: config => { // iview Loader config.module .rule("vue") .test(/\.vue$/) .use("iview-loader") .loader("iview-loader") .options({ prefix: true, }) .end(); }, configureWebpack: { devtool: "source-map", plugins: [new webpack.IgnorePlugin(/^\.\/locale$/, /moment|iview$/)], }, pwa: { workboxPluginMode: "GenerateSW", workboxOptions: { importWorkboxFrom: "local", // navigateFallback: "index.html", skipWaiting: true, clientsClaim: true, runtimeCaching: [ { // 背景图如果要换,就改地址,减少网络消耗 urlPattern: new RegExp( "^https://cdn.qmth.com.cn/ui/ecs-client-bg.jpg!/progressive/true" ), handler: "cacheFirst", options: { cacheableResponse: { statuses: [0, 200], }, }, }, { // Match any same-origin request that contains 'api'. // 产品名称有可能每分钟都更新 urlPattern: /\/api\/ecs_core\/org\/propertyNoSession\/OE_STUDENT_SYS_NAME\?domainName=/, handler: "cacheFirst", options: { cacheableResponse: { statuses: [0, 200], }, cacheName: "sys-name-cache", expiration: { maxAgeSeconds: 60, }, }, }, { // Match any same-origin request that contains 'api'. // logo 每天更新一次 urlPattern: /\/api\/ecs_core\/org\/logo\?domain=/, handler: "cacheFirst", options: { cacheableResponse: { statuses: [0, 200], }, cacheName: "logo-cache", expiration: { maxAgeSeconds: 24 * 60 * 60, }, }, }, { urlPattern: /\/models\/.*\/.*\.json/, handler: "cacheFirst", options: { cacheableResponse: { statuses: [0, 200], }, }, }, { // Match any same-origin request that contains 'api'. // 客观分10分钟更新一次 urlPattern: /\/api\/ecs_oe_student\/examScore\/queryObjectiveScoreList\?examStudentId=/, handler: "cacheFirst", options: { cacheableResponse: { statuses: [0, 200], }, cacheName: "objective-score-list-cache", expiration: { maxAgeSeconds: 10 * 60, }, }, }, { // 站内消息3分钟获取一次 urlPattern: /\/api\/ecs_exam_work\/notice\/getUserNoticeList\?/, handler: "cacheFirst", options: { cacheableResponse: { statuses: [0, 200], }, cacheName: "site-messages-list-cache", expiration: { maxAgeSeconds: 3 * 60, }, }, }, ], }, }, };