From 96ddcb312a69bd5595bdf2e9d356aebb6905f420 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sun, 5 Jun 2022 19:50:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dconfig.json=E8=A2=AB?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E5=AF=BC=E8=87=B4=E5=8F=98=E6=9B=B4=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=8F=8A=E6=97=B6=E6=9B=B4=E6=96=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit config.json的变化不会被webpack感知到,因此不应该被sw缓存 --- web/build/webpack.config.ts | 2 +- web/src/init.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/build/webpack.config.ts b/web/build/webpack.config.ts index c34d8dad..e8eae77c 100644 --- a/web/build/webpack.config.ts +++ b/web/build/webpack.config.ts @@ -102,7 +102,7 @@ const plugins: Configuration['plugins'] = [ skipWaiting: true, // Do not precache images - exclude: [/\.(?:png|jpg|jpeg|svg)$/], + exclude: [/\.(?:png|jpg|jpeg|svg)$/, 'config.json'], maximumFileSizeToCacheInBytes: 8 * 1024 * 1024, // 限制最大缓存 8M diff --git a/web/src/init.tsx b/web/src/init.tsx index 2e904c70..b31d0665 100644 --- a/web/src/init.tsx +++ b/web/src/init.tsx @@ -66,7 +66,7 @@ setGlobalLoading((text) => { * 获取前端配置 */ request - .get('/config.json', { + .get('/config.json?v2', { baseURL: '', }) .then(({ data: config }) => {