Skip to content

Commit

Permalink
🔨 chore: improve next config (lobehub#2044)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Apr 15, 2024
1 parent ea51c3a commit dbfa63f
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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));

0 comments on commit dbfa63f

Please sign in to comment.