Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Conversation

@larrifax
Copy link
Contributor

Is projectRoot always the path to the directory containing cypress.json? In that case, a directory structure like the following would make the pagesDir refer to a incorrect directory:

./ ├─ src/ │ ├─ pages/ │ ├─ components/ ├─ cypress/ ├─ cypress.json ├─ package.json 

It may well be that it doesn't have any adverse affects though. And if so, only for tests written against page-components.

@bahmutov
Copy link
Contributor Author

Question - how does "regular" Next.js know what folder to use: /pages or /src/pages?

@bahmutov
Copy link
Contributor Author

I will land this fix (since it can solve at least some problems) and we can look at /pages vs /src/pages separately

@bahmutov bahmutov marked this pull request as ready for review October 27, 2020 14:07
@bahmutov bahmutov changed the title Nextjs pages fix: set Next.js pages to load from /pages folder Oct 27, 2020
@bahmutov bahmutov merged commit bf07210 into main Oct 27, 2020
@bahmutov bahmutov deleted the nextjs-pages branch October 27, 2020 14:07
@larrifax
Copy link
Contributor

Question - how does "regular" Next.js know what folder to use: /pages or /src/pages?

Good question! Hadn't thought about that. Seems like they look for both paths, ref. https://nextjs.org/docs/advanced-features/src-directory

@bahmutov
Copy link
Contributor Author

🎉 This PR is included in version 4.16.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@bahmutov
Copy link
Contributor Author

Ha, @larrifax I think we could change this line to

const rootPages = path.join(config.projectRoot, 'pages') const srcPages = path.join(config.projectRoot, 'src', 'pages') pagesDir: fs.existsSync(rootPages) ? rootPages : srcPages
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3 participants