Skip to content

Commit

Permalink
chore: fix bundle analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasio committed Oct 28, 2024
1 parent e37be5e commit 9b06fb0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/nextjs_bundle_analysis-app-router.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
defaults:
run:
# change this if your nextjs app does not live at the root of the repo
working-directory: ./
working-directory: ./projects/wp-nextjs-app

jobs:
analyze:
Expand All @@ -24,7 +24,7 @@ jobs:
node-version: '20.x'

- name: Install dependencies
uses: bahmutov/npm-install@v1
run: npm ci

- name: Restore next build
uses: actions/cache@v2
Expand All @@ -34,13 +34,13 @@ jobs:
with:
# if you use a custom build directory, replace all instances of `.next` in this file with your build directory
# ex: if your app builds to `dist`, replace `.next` with `dist`
path: ./projects/wp-nextjs-app/.next/cache
path: .next/cache
# change this if you prefer a more strict cache
key: ${{ runner.os }}-build-${{ env.cache-name }}

- name: Build next.js app
# change this if your site requires a custom build command
run: npm run build -- --filter=@10up/wp-nextjs-app
run: cd ../../ && npm run build -- --filter=@10up/wp-nextjs-app

# Here's the first place where next-bundle-analysis' own script is used
# This step pulls the raw bundle stats for the current bundle
Expand All @@ -51,15 +51,15 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: bundle
path: ./projects/wp-nextjs-app/.next/analyze/__bundle_analysis.json
path: .next/analyze/__bundle_analysis.json

- name: Download base branch bundle stats
uses: dawidd6/action-download-artifact@v2
if: success() && github.event.number
with:
workflow: nextjs_bundle_analysis.yml
branch: ${{ github.event.pull_request.base.ref }}
path: ./projects/wp-nextjs-app/.next/analyze/base
path: .next/analyze/base

# And here's the second place - this runs after we have both the current and
# base branch bundle stats, and will compare them to determine what changed.
Expand All @@ -76,13 +76,13 @@ jobs:
# entry in your package.json file.
- name: Compare with base branch bundle
if: success() && github.event.number
run: ls -laR ./projects/wp-nextjs-app/.next/analyze/base && npx -p nextjs-bundle-analysis compare
run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare

- name: Get comment body
id: get-comment-body
if: success() && github.event.number
run: |
body=$(cat ./projects/wp-nextjs-app/.next/analyze/__bundle_analysis_comment.txt)
body=$(cat .next/analyze/__bundle_analysis_comment.txt)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
Expand Down
5 changes: 5 additions & 0 deletions projects/wp-nextjs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
"start": "next start",
"lint": "eslint ."
},
"nextBundleAnalysis": {
"budget": 148480,
"budgetPercentIncreaseRed": 20,
"showDetails": true
},
"dependencies": {
"react": "^18",
"react-dom": "^18",
Expand Down

0 comments on commit 9b06fb0

Please sign in to comment.