Run scripts during build time
Answered
Anay-208 posted this in #help-forum
Anay-208OP
I want to run scripts during build time, like for each individual page
Since I'm using cloudflare images, Is there any way, like during build, I can get all the sizes which nextjs has given to the user in srcset, and put it in my allowlist?
Runtime of all my pages are edge if it affects something
So I want to run something similar to
Since I'm using cloudflare images, Is there any way, like during build, I can get all the sizes which nextjs has given to the user in srcset, and put it in my allowlist?
Runtime of all my pages are edge if it affects something
So I want to run something similar to
getStaticProps during build timeAnswered by joulev
write a script, run it in the build step
{
"scripts": {
"build": "node scripts/do-stuff.js && next build"
}
}4 Replies
Anay-208OP
I need to basically execute for each route, a different one
Anay-208OP
Only solution I found is to use unstable cache, which'll execute only on first request.
I didn't find anything during build time, as I'm using edge runtime
I didn't find anything during build time, as I'm using edge runtime
@Anay-208 I want to run scripts during build time, like for each individual page
Since I'm using cloudflare images, Is there any way, like during build, I can get all the sizes which nextjs has given to the user in srcset, and put it in my allowlist?
Runtime of all my pages are edge if it affects something
So I want to run something similar to `getStaticProps` during build time
write a script, run it in the build step
{
"scripts": {
"build": "node scripts/do-stuff.js && next build"
}
}Answer
output in json and simply import that json to your page