diff --git a/packages/gatsby-plugin-sharp/.gitignore b/packages/gatsby-plugin-sharp/.gitignore index a331b6826346d..f8e91069da686 100644 --- a/packages/gatsby-plugin-sharp/.gitignore +++ b/packages/gatsby-plugin-sharp/.gitignore @@ -1,7 +1,2 @@ -/index.js /node_modules -/gatsby-node.js -/duotone.js -/queue.js -/processFile.js -/scheduler.js +/*.js diff --git a/packages/gatsby-plugin-sharp/src/gatsby-node.js b/packages/gatsby-plugin-sharp/src/gatsby-node.js index 67e73303d9351..6dfd89373e01a 100644 --- a/packages/gatsby-plugin-sharp/src/gatsby-node.js +++ b/packages/gatsby-plugin-sharp/src/gatsby-node.js @@ -44,7 +44,6 @@ let promises = [] exports.onPreBuild = async ({ cache, boundActionCreators }, pluginOptions) => { const cachedQueue = await getQueueFromCache(cache) - let promises = [] for (const [, job] of cachedQueue) { promises.push(scheduleJob(job, boundActionCreators, pluginOptions)) } @@ -74,6 +73,10 @@ exports.onCreateDevServer = ({ app, cache }, pluginOptions) => { // wait until the file has been processed and saved to disk await Promise.all(processFile(job.file.absolutePath, [job], pluginOptions)) + queue.delete(req.originalUrl) + + // JSON.stringify doesn't work on an Map so we need to convert it to an array + cache.set(`queue`, Array.from(queue)) return res.sendFile(job.outputPath) })