Is this supported somehow? I'd like to execute arbitrary code to post-process the built HTML/css/etc after next.js does its thing.
Asked
Active
Viewed 5,832 times
5
-
1Does a `postbuild` command work in your package.json? Maybe test something simple like echoing a value at first. You can also have a custom build command, so you could simply run `yarn run build && your-custom-script` – Eric Burel Mar 31 '21 at 07:47
-
Your 2nd suggestion worked if you want to add it as an answer. – Joren Apr 01 '21 at 17:33
-
Done, and did you try the `postbuild` thing? The limitation is that it would run on your local builds as well which can become annoying during dev. – Eric Burel Apr 02 '21 at 07:45
-
postbuild somehow doesn't get triggered by vercel – Kevin Kreps Jan 24 '22 at 17:52
1 Answers
6
You can use a custom build command in Vercel, that does both the build and the postbuild: yarn run build && yarn run your-postbuild-script
.

Eric Burel
- 3,790
- 2
- 35
- 56
-
3I'm looking to run an external script after Vercel finishes building and deploying in prod. Your current solution would just run them one after the other? – Augusto Samamé Barrientos Aug 20 '21 at 19:44
-
So your question is not about post-build, but about post-deploy, which is another issue. I don't know how to solve this, I'd be tempted to trigger the script post-build and add a kind of timer to wait for the website to be probably ready (like build + 5 minutes shoud be enough to deploy). I don't know about detecting a successful deploy. – Eric Burel Aug 23 '21 at 08:10
-