From dbfa63ff230ec6723205e519ad95d8e21a07cac8 Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Mon, 15 Apr 2024 10:53:25 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20chore:=20improve=20next=20config?= =?UTF-8?q?=20(#2044)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- next.config.mjs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/next.config.mjs b/next.config.mjs index 1b97f0fd802b..634aeaf5d322 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -9,18 +9,6 @@ const API_PROXY_ENDPOINT = process.env.API_PROXY_ENDPOINT || ''; const basePath = process.env.NEXT_PUBLIC_BASE_PATH; -const withBundleAnalyzer = analyzer({ - enabled: process.env.ANALYZE === 'true', -}); - -const withPWA = nextPWA({ - dest: 'public', - register: true, - workboxOptions: { - skipWaiting: true, - }, -}); - /** @type {import('next').NextConfig} */ const nextConfig = { compress: isProd, @@ -67,4 +55,18 @@ const nextConfig = { }, }; -export default isProd ? withBundleAnalyzer(withPWA(nextConfig)) : nextConfig; +const noWrapper = (config) => config; + +const withBundleAnalyzer = process.env.ANALYZE === 'true' ? analyzer() : noWrapper; + +const withPWA = isProd + ? nextPWA({ + dest: 'public', + register: true, + workboxOptions: { + skipWaiting: true, + }, + }) + : noWrapper; + +export default withBundleAnalyzer(withPWA(nextConfig));