Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ export const onPostBuild = async ({ store, pathPrefix, reporter }: any, userPlug

;[...pages.values()].forEach((page) => {
const { mode, matchPath, path } = page
const matchPathClean = matchPath && matchPath.replace(/\*.*/, '*')
const matchPathIsNotPath = matchPath && matchPath !== path

if (mode === `SSR` || mode === `DSG`) {
needsFunctions = true
const fromPath = matchPath ?? path
const fromPath = matchPathClean ?? path
const toPath = mode === `SSR` ? `/.netlify/functions/__ssr` : `/.netlify/functions/__dsg`
count++
rewrites.push(
Expand All @@ -91,10 +94,9 @@ export const onPostBuild = async ({ store, pathPrefix, reporter }: any, userPlug
toPath,
},
)
}
if (pluginOptions.generateMatchPathRewrites && matchPath && matchPath !== path) {
} else if (pluginOptions.generateMatchPathRewrites && matchPathIsNotPath) {
rewrites.push({
fromPath: matchPath,
fromPath: matchPathClean,
toPath: path,
})
}
Expand Down