diff --git a/packages/gatsby/cache-dir/loader.js b/packages/gatsby/cache-dir/loader.js index 4a6941948c837..6fd5e9b6799bb 100644 --- a/packages/gatsby/cache-dir/loader.js +++ b/packages/gatsby/cache-dir/loader.js @@ -243,7 +243,7 @@ const queue = { const pageResources = { component: syncRequires.components[page.componentChunkName], json: syncRequires.json[page.jsonName], - layout: syncRequires.layouts[page.layoutComponentChunkName], + layout: syncRequires.layouts[page.layout], page, } cb(pageResources) @@ -308,7 +308,7 @@ const queue = { }) page.layoutComponentChunkName && - getResourceModule(page.layoutComponentChunkName, (err, l) => { + getResourceModule(page.layout, (err, l) => { if (err) { console.log(`Loading the Layout for ${page.path} failed`) } diff --git a/packages/gatsby/cache-dir/static-entry.js b/packages/gatsby/cache-dir/static-entry.js index 6888bf6d339e9..1df41d1581b41 100644 --- a/packages/gatsby/cache-dir/static-entry.js +++ b/packages/gatsby/cache-dir/static-entry.js @@ -33,7 +33,7 @@ const getPage = path => pages.find(page => page.path === path) const defaultLayout = props =>
{props.children()}
const getLayout = page => { - const layout = syncRequires.layouts[page.layoutComponentChunkName] + const layout = syncRequires.layouts[page.layout] return layout ? layout : defaultLayout } diff --git a/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js b/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js index 08dc39c343928..98d4c1740b429 100644 --- a/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js +++ b/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js @@ -86,7 +86,7 @@ const preferDefault = m => m && m.default || m syncRequires += `exports.layouts = {\n${pageLayouts .map( l => - ` "${l.componentChunkName}": preferDefault(require("${ + ` "${l.id}": preferDefault(require("${ l.componentWrapperPath }"))` ) @@ -124,7 +124,7 @@ const preferDefault = m => m && m.default || m asyncRequires += `exports.layouts = {\n${pageLayouts .map( l => - ` "${l.componentChunkName}": require("gatsby-module-loader?name=${ + ` "${l.id}": require("gatsby-module-loader?name=${ l.componentChunkName }!${l.componentWrapperPath}")` )