From d1a588d01b87540a4f2209bd5f934430f0e1182d Mon Sep 17 00:00:00 2001 From: Steven Surgnier Date: Mon, 29 Jan 2018 14:53:09 -0500 Subject: [PATCH] use createPage singleton in dev-404-page closes #3551 --- .../internal-plugins/dev-404-page/gatsby-node.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/gatsby/src/internal-plugins/dev-404-page/gatsby-node.js b/packages/gatsby/src/internal-plugins/dev-404-page/gatsby-node.js index 8540086d2d3ca..7a381d26b228d 100644 --- a/packages/gatsby/src/internal-plugins/dev-404-page/gatsby-node.js +++ b/packages/gatsby/src/internal-plugins/dev-404-page/gatsby-node.js @@ -1,6 +1,8 @@ const path = require(`path`) const fs = require(`fs-extra`) +let createdPage = false + exports.createPages = async ({ store, boundActionCreators }) => { if (process.env.NODE_ENV !== `production`) { const { program } = store.getState() @@ -8,11 +10,15 @@ exports.createPages = async ({ store, boundActionCreators }) => { const currentPath = path.join(__dirname, `./raw_dev-404-page.js`) const newPath = path.join(program.directory, `.cache`, `dev-404-page.js`) - await fs.copy(currentPath, newPath) + if (!createdPage) { + createdPage = true + + await fs.copy(currentPath, newPath) - createPage({ - component: newPath, - path: `/dev-404-page/`, - }) + createPage({ + component: newPath, + path: `/dev-404-page/`, + }) + } } }