Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nextjs-starter-template
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Moorthy G
nextjs-starter-template
Commits
3140a4b4
Commit
3140a4b4
authored
Jun 12, 2025
by
Moorthy G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(next.config): load bundle analyzer with dynamic import
parent
2ae69057
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
next.config.mjs
next.config.mjs
+14
-6
No files found.
next.config.mjs
View file @
3140a4b4
import withBundleAnalyzer from '@next/bundle-analyzer';
const bundleAnalyzer = withBundleAnalyzer({
enabled: process.env.ANALYZE === 'true'
});
// Conditionally import @next/bundle-analyzer only if ANALYZE is true
const getBundleAnalyzer = async () => {
if (process.env.ANALYZE === 'true') {
const withBundleAnalyzer = (await import('@next/bundle-analyzer')).default;
return withBundleAnalyzer({ enabled: true });
}
return (config) => config;
};
/** @type {import('next').NextConfig} */
const nextConfig = {
...
...
@@ -27,4 +30,9 @@ const nextConfig = {
compress: false
};
export default bundleAnalyzer(nextConfig);
const getConfig = async () => {
const bundleAnalyzer = await getBundleAnalyzer();
return bundleAnalyzer(nextConfig);
};
export default getConfig();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment