Skip to content

Github Action that analyses page bundle sizes from a Next.js build

Notifications You must be signed in to change notification settings

transferwise/actions-next-bundle-analyzer

Repository files navigation

actions-next-bundle-analyzer

GitHub action that analyses the bundle sizes for each route in a Next.js build.

Usage

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 }}

On a Pull Request

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:

image

Note: Difference to the default branch will only be shown once this action has run on a default branch commit.

On the default branch

When the workflow runs on the default branch, it will create/update a GitHub Issue with the current bundle sizes.

image

Contributing

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.

About

Github Action that analyses page bundle sizes from a Next.js build

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published