Skip to content

Commit 1cc6940

Browse files
committed
feat(codecov): bundle analyzer
1 parent c11af00 commit 1cc6940

File tree

4 files changed

+251
-43
lines changed

4 files changed

+251
-43
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ jobs:
104104
NODE_OPTIONS: '--max_old_space_size=4096'
105105
# Used for API requests that require GitHub API scopes
106106
NEXT_GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }}
107+
# Codecov
108+
ANALYZE: ${{ matrix.os == 'ubuntu-latest' && github.event_name != 'merge_group' }}
107109

108110
- name: Build Next.js (Static All Locales)
109111
# We only run full static builds within Pull Requests. This step is also used to export

apps/site/next.config.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
import { codecovNextJSWebpackPlugin } from '@codecov/nextjs-webpack-plugin';
23
import createNextIntlPlugin from 'next-intl/plugin';
34

45
import { BASE_PATH, ENABLE_STATIC_EXPORT } from './next.constants.mjs';
@@ -96,6 +97,23 @@ const nextConfig = {
9697
'shiki',
9798
],
9899
},
100+
webpack: (config, options) => {
101+
if (process.env.ANALYZE) {
102+
config.plugins.push(
103+
codecovNextJSWebpackPlugin({
104+
enableBundleAnalysis: true,
105+
// If CODECOV_TOKEN isn't specified, a tokenless
106+
// upload will work as well.
107+
uploadToken: process.env.CODECOV_TOKEN,
108+
bundleName: '@node-core/website',
109+
webpack: options.webpack,
110+
telemetry: false,
111+
})
112+
);
113+
}
114+
115+
return config;
116+
},
99117
};
100118

101119
const withNextIntl = createNextIntlPlugin('./i18n.tsx');

apps/site/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"vfile-matter": "~5.0.1"
7575
},
7676
"devDependencies": {
77+
"@codecov/nextjs-webpack-plugin": "^1.9.1",
7778
"@eslint/compat": "~1.2.8",
7879
"@eslint/eslintrc": "~3.3.1",
7980
"@flarelabs-net/wrangler-build-time-fs-assets-polyfilling": "^0.0.0",

0 commit comments

Comments
 (0)