GitHub action that analyses the bundle sizes for each route in a Next.js build.
Add the following step to a workflow which runs on a pull_request event, after the Next.js project has been built (i.e. after running pnpm run build
).
- name: Analyze bundle sizes
uses: transferwise/actions-next-bundle-analyzer@v2
with:
# Optional, specifies where to look for .next folder. Defaults to cwd.
working-directory: ./apps/my-next-app
# Optional, configures commenting strategy around insignificant changes, defaults to `always`.
# Available options:
# always: Always comment on PRs, even if it's just to say there are no significant changes.
# skip-insignificant: Skip commenting on PRs if there are no signficant changes in page sizes.
comment-strategy: 'always'
# Optional, configures whether to create the bundle size summary issue, defaults to `true`.
# Available options:
# true
# false
create-issue: true
# Optional, defaults to `github.token`.
github-token: ${{ github.token }}
When the job runs on a pull request a comment will be added showing the bundle sizes of the branch and the difference against the default branch:
Note: Difference to the default branch will only be shown once this action has run on a default branch commit.
When the workflow runs on the default branch, it will create/update a GitHub Issue with the current bundle sizes.
Compiled files must also be commited. After making changes to TypeScript files run
pnpm run build
Add both the source files and the new compiled files to your pull request.