8000 feat(nextjs): Add post-build script for Vercel testing (#4053) · andreialecu/sentry-javascript@2dbe5d7 · GitHub < 8000 meta name="release" content="38cb7bfbf9dd21d343725f1f1d774302824cf43d">
[go: up one dir, main page]

Skip to content

Commit 2dbe5d7

Browse files
authored
feat(nextjs): Add post-build script for Vercel testing (getsentry#4053)
This adds a script to be run after the nextjs app is built when testing an SDK branch on Vercel. More specifically, it - moves the command to make the bundle analysis files available on the deployed app from a one-liner in the Vercel project settings to a script (because the code to do that correctly turns out to be a little more complicated than we thought), - looks in the correct location for files created by `experimental-serverless-trace` builds, and - only attempts to move the files if they exist.
1 parent 2138f13 commit 2dbe5d7

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

packages/nextjs/vercel/instructions.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ commit (but not push) this change.
3333

3434
Go into your project settings on Vercel and change the install command to
3535

36-
`bash .sentry/install-sentry-from-branch.sh`.
36+
`bash .sentry/install-sentry-from-branch.sh`
3737

38-
If you're using bundle analyzer, change the build command to
38+
and the build command to
3939

40-
`yarn build && mv .next/analyze/* public`.
40+
`yarn build && bash .sentry/post-app-build.sh`.
4141

42-
The bundle visualizations will be available on your deployed site at `/client.html` and `/server.html`.
42+
If you're using bundle analyzer, the post-build script will move the visualizations it creates so that they're available
43+
on your deployed site at `/client.html` and `/server.html`.
4344

4445
NOTE: You don't need to change the `@sentry/nextjs` dependency in your project's `package.json` file. That will happen
4546
on the fly each time your app is deployed.

packages/nextjs/vercel/make-project-use-current-branch.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ mkdir .sentry
4040
echo " "
4141
echo "Creating install scripts and committing the changes"
4242
cp $NEXTJS_SDK_DIR/vercel/install-sentry-from-branch.sh .sentry
43+
cp $NEXTJS_SDK_DIR/vercel/post-app-build.sh .sentry
4344
echo "export BRANCH_NAME=${SDK_BRANCH_NAME}" >>.sentry/set-branch-name.sh
4445
git add .
4546
git commit -m "add scripts for using ${SDK_BRANCH_NAME} branch of @sentry/nextjs"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SCRIPT TO INCLUDE AS PART OF A VERCEL-DEPLOYED PROJECT, FOR WORK TO BE DONE AFTER THE NEXTJS APP IS BUILT
2+
# USE `yarn vercel:project <path-to-project>` TO HAVE IT AUTOMATICALLY ADDED TO YOUR PROJECT
3+
4+
# CUSTOM BUILD COMMAND FOR PROJECT ON VERCEL: `yarn build && bash .sentry/post-app-build.sh`
5+
6+
if [[ -e .next/analyze/ ]]; then
7+
echo " "
8+
echo "Moving bundle analysis graphs from \`.next/analyze/\` to \`/public\`"
9+
mv .next/analyze/* public
10+
fi
11+
if [[ -e .next/server/analyze/ ]]; then
12+
echo " "
13+
echo "Moving bundle analysis graphs from \`.next/server/analyze/\` to \`/public\`"
14+
mv .next/server/analyze/* public
15+
echo " "
16+
fi

0 commit comments

Comments
 (0)
0