Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit 4968928

Browse files
fix: don't exclude _error page from build
1 parent e8415fc commit 4968928

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/__tests__/getNextPagesFromBuildDir.test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,16 @@ describe("getNextPagesFromBuildDir", () => {
7373
});
7474
});
7575

76-
it("should skip _ pages like app, document and error", () => {
77-
expect.assertions(1);
76+
it("should skip _app and _document pages", () => {
77+
expect.assertions(2);
7878

7979
fs.readdir.mockImplementationOnce((path, cb) =>
80-
cb(null, ["_app", "_document"])
80+
cb(null, ["_app.js", "_document.js", "_error.js"])
8181
);
8282

8383
return getNextPagesFromBuildDir("/path/to/build").then(nextPages => {
84-
expect(nextPages).toEqual([]);
84+
expect(nextPages).toHaveLength(1);
85+
expect(nextPages[0].pageName).toEqual("_error");
8586
});
8687
});
8788

lib/getNextPagesFromBuildDir.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ const logPages = nextPages => {
1111
logger.log(`Found ${pageNames.length} next page(s)`);
1212
};
1313

14+
const excludeBuildFiles = ["_app.js", "_document.js", "compatLayer.js"];
15+
1416
module.exports = async (buildDir, pageConfig = {}) => {
1517
const buildFiles = await readdirAsync(buildDir);
1618

1719
const nextPages = buildFiles
18-
.filter(bf => !bf.startsWith("_") && bf !== "compatLayer.js")
20+
.filter(bf => {
21+
console.log(bf);
22+
return !excludeBuildFiles.includes(bf);
23+
})
1924
.map(fileName => {
2025
const pagePath = path.join(buildDir, fileName);
2126

0 commit comments

Comments
 (0)