Commit 3140a4b4 by Moorthy G

refactor(next.config): load bundle analyzer with dynamic import

parent 2ae69057
import withBundleAnalyzer from '@next/bundle-analyzer'; // Conditionally import @next/bundle-analyzer only if ANALYZE is true
const getBundleAnalyzer = async () => {
const bundleAnalyzer = withBundleAnalyzer({ if (process.env.ANALYZE === 'true') {
enabled: process.env.ANALYZE === 'true' const withBundleAnalyzer = (await import('@next/bundle-analyzer')).default;
}); return withBundleAnalyzer({ enabled: true });
}
return (config) => config;
};
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
...@@ -27,4 +30,9 @@ const nextConfig = { ...@@ -27,4 +30,9 @@ const nextConfig = {
compress: false compress: false
}; };
export default bundleAnalyzer(nextConfig); const getConfig = async () => {
const bundleAnalyzer = await getBundleAnalyzer();
return bundleAnalyzer(nextConfig);
};
export default getConfig();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment