badgen.net
badgen.net copied to clipboard
Move to another page generator
We are using Next.js static exports with now 2.0 deployments, now we want to limit function memory to a smaller size.
Adding a functions
config to now.json
:
"functions": {
"api/*.ts": {
"memory": 512
}
},
caused this error:
> Error! The property `builds` is not allowed in now.json when using Now 2.0 – please remove it.
Actually
builds
is allowed whenversion
is2
, just don't use it withfunctions
If we don't use builds
(so no @now/static
or @now/static-build
), then we need to export pages to public
dir (other than dist
) to meet zero-config's requirement.
While, Next.js doesn't allow exporting to public
dir. There's a workaround for this, but it need to setup a builds
fields in now.json
, which is disallowed when deploying to now v2, which is what happened in the beginning 🤦♂️
So finally, the solution could be moving to another static page generator, which exports to public
folder.
If you remove builds
property from now.json, it should "just work" without any additional configuration.
If you remove
builds
property from now.json, it should "just work" without any additional configuration.
Removed builds
property https://badgennet-b7t1t7wa0.now.sh
@styfle htmls are fine but statics (js, css, etc) are missing
Seems like static
should be public
like the docs mention here: https://nextjs.org/docs/basic-features/static-file-serving
Also, you could probably move /api
to /pages/api
and then you can develop with next dev
locally. It will likely speed up the production deployment time too since everything can be handed to Next.js instead of assuming each api needs separate dependencies.