diff --git a/.github/workflows/build_reusable.yml b/.github/workflows/build_reusable.yml index 849580725961a..87ad391ddb36d 100644 --- a/.github/workflows/build_reusable.yml +++ b/.github/workflows/build_reusable.yml @@ -21,6 +21,10 @@ on: required: false description: 'whether to skip building native modules' type: string + uploadAnalyzerArtifacts: + required: false + description: 'whether to upload analyzer artifacts' + type: string skipForDocsOnly: required: false description: 'skip for docs only changes' @@ -166,7 +170,7 @@ jobs: - run: pnpm install if: ${{ inputs.skipInstallBuild != 'yes' }} - - run: pnpm build + - run: ANALYZE=1 pnpm build if: ${{ inputs.skipInstallBuild != 'yes' }} - run: pnpm playwright install-deps @@ -186,6 +190,13 @@ jobs: name: turbo run summary path: .turbo/runs + - name: Upload bundle analyzer artifacts + uses: actions/upload-artifact@v3 + if: ${{ inputs.uploadAnalyzerArtifacts == 'yes' }} + with: + name: webpack bundle analysis stats + path: packages/next/dist/compiled/next-server/report.*.html + - name: Upload test reports artifact uses: actions/upload-artifact@v3 if: ${{ inputs.afterBuild }} diff --git a/.github/workflows/pull_request_stats.yml b/.github/workflows/pull_request_stats.yml index c88e5a76ad256..f3cc73e5ae5ce 100644 --- a/.github/workflows/pull_request_stats.yml +++ b/.github/workflows/pull_request_stats.yml @@ -26,6 +26,7 @@ jobs: secrets: inherit with: uploadSwcArtifact: 'yes' + uploadAnalyzerArtifacts: 'yes' stats: name: PR Stats diff --git a/packages/next/webpack.config.js b/packages/next/webpack.config.js index 1a2039ea4464f..39f025222e2b4 100644 --- a/packages/next/webpack.config.js +++ b/packages/next/webpack.config.js @@ -187,6 +187,19 @@ module.exports = ({ dev, turbo, bundleType, experimental }) => { bundleType ), openAnalyzer: false, + ...(process.env.CI + ? { + analyzerMode: 'static', + reportFilename: path.join( + __dirname, + `dist/compiled/next-server/report.${dev ? 'dev' : 'prod'}-${ + turbo ? 'turbo' : 'webpack' + }-${ + experimental ? 'experimental' : 'stable' + }-${bundleType}.html` + ), + } + : {}), }), ].filter(Boolean), stats: {