Skip to content

Commit b02305e

Browse files
szimekKyleAMathews
authored andcommitted
Fix issue that Gatsby can't sometimes find layout and page files on Windows (#3796)
* Fix issue with missing layouts on Windows * Fix issue with missing pages on Windows
1 parent 869bb2c commit b02305e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

packages/gatsby/src/internal-plugins/component-layout-creator/gatsby-node.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@ exports.createLayouts = async (
1919
) => {
2020
const { createLayout, deleteLayout } = boundActionCreators
2121
const program = store.getState().program
22+
const exts = program.extensions.map(e => `${e.slice(1)}`).join(`,`)
2223
const layoutDirectory = systemPath.posix.join(
2324
program.directory,
2425
`/src/layouts`
2526
)
26-
const exts = program.extensions.map(e => `${e.slice(1)}`).join(`,`)
27+
const layoutGlob = `${layoutDirectory}/**/*.{${exts}}`
2728

2829
// Get initial list of files.
29-
let files = await glob(`${layoutDirectory}/**/?(${exts})`)
30+
let files = await glob(layoutGlob)
3031
files.forEach(file => _createLayout(file, layoutDirectory, createLayout))
3132

3233
// Listen for new layouts to be added or removed.
3334
chokidar
34-
.watch(`${layoutDirectory}/**/*.{${exts}}`)
35+
.watch(layoutGlob)
3536
.on(`add`, path => {
3637
if (!_.includes(files, path)) {
3738
_createLayout(path, layoutDirectory, createLayout)

packages/gatsby/src/internal-plugins/component-page-creator/gatsby-node.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@ exports.createPagesStatefully = async (
2121
) => {
2222
const { createPage, deletePage } = boundActionCreators
2323
const program = store.getState().program
24-
const pagesDirectory = systemPath.posix.join(program.directory, `/src/pages`)
2524
const exts = program.extensions.map(e => `${e.slice(1)}`).join(`,`)
25+
const pagesDirectory = systemPath.posix.join(program.directory, `/src/pages`)
26+
const pagesGlob = `${pagesDirectory}/**/*.{${exts}}`
2627

2728
// Get initial list of files.
28-
let files = await glob(`${pagesDirectory}/**/?(${exts})`)
29+
let files = await glob(pagesGlob)
2930
files.forEach(file => _createPage(file, pagesDirectory, createPage))
3031

3132
// Listen for new component pages to be added or removed.
3233
chokidar
33-
.watch(`${pagesDirectory}/**/*.{${exts}}`)
34+
.watch(pagesGlob)
3435
.on(`add`, path => {
3536
if (!_.includes(files, path)) {
3637
_createPage(path, pagesDirectory, createPage)

0 commit comments

Comments
 (0)