.vercelignore file?
I have published many sites on Pages using the next-on-pages tool. In the past, my projects only contained the Next.js app and nothing else.
This week, I'm trying to set up a site that includes the Next.js app but also a Sanity.io studio install. The project can be used to build the Next.js project and run Sanity Studio for authors.
Sanity Studio keeps a set of key schema files in a directory called
Sanity Studio keeps a set of key schema files in a directory called
schema
. This directory is not needed for building the Next.js project and can/should be ignored by Next.js or next-on-pages activity.
The problem:
Running npx @cloudflare/next-on-pages@1
results in a type error for the Sanity schema that blocks the build.
Attempted (and failed) fixes:
* Hide the folder with the offending files by renaming /schema
to /.schema
.
* Add a .vercelignore
file with schema
as the lone entry.
* Add schema
to the tsconfig.json
file in the project to exclude the directory from type checking.
* Added schema
to the .gitignore
as a test (this won't be acceptable as a solution) but that also failed.
* Experimented with wrangler.toml
to see if there's a way to do it there, but I don't think that runs on prod builds anyhow so..../shrug
* Tried all of the above at the same time, just in case...but no joy.
How can I tell next-on-pages to ignore a set of files or directories on build?5 Replies
What about moving
/schema
to /tmp/schema
?Good idea, but failed. I also tried updating tsconfig.json to include
/tmp/schema
when it failed on first try. That did not change things. I suspect that the various exclude entries are being ignored? Or, maybe I have to find a way to handle this with the next build
step (which I can't seem to find)?Just to confirm, if you entirely delete it, does it still not work? If so, then I'm going to guess the issue is something else entirely...
If deleted, it works. I think I found it: There was a
sanity.conf.ts
file in the root of the project that was not ignored. That has an import to files in the schema directory. When I excluded that in tsconfig.json
things worked and built properly.
I have to do more testing, but that might be the answer...which is acceptable given the current setup for Sanity Studio is not type checking correctly. BUT, long-term that wouldn't work if both need type checking and then the answer (if there's no .vercelignore used) might be "split them into two projects". 😦
(Confirmed, the site built and deployed to cloudflare with that ignore line added...but is there a config option that lets me ignore directories not related to pages? I don't think I'm technically at the 'monorepo' state here but it's in that family, maybe?)Not at the moment.