badgen.net icon indicating copy to clipboard operation
badgen.net copied to clipboard

Move to another page generator

Open amio opened this issue 5 years ago • 3 comments

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 when version is 2, just don't use it with functions

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.

amio avatar Jan 26 '20 11:01 amio

If you remove builds property from now.json, it should "just work" without any additional configuration.

styfle avatar Jan 26 '20 22:01 styfle

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

image

amio avatar Jan 27 '20 03:01 amio

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.

styfle avatar Jan 29 '20 20:01 styfle