Among the final bootstrap phases before Gatsby hands off the site to Webpack for bundling and code optimization is the process of writing out pages. Because Webpack has no awareness of Gatsby source code or Redux stores and operates on only files in Gatsby’s .cache directory, Gatsby needs to create JavaScript files for behavior and JSON files for data that the Webpack configuration set out by Gatsby can accept.
TIP
For a diagram illustrating the flow of this bootstrap stage, consult the Gatsby documentation’s guide to writing out pages.
In the process of writing out pages, primary logic is found in src/internal-plugins/query-runner/pages-writer.js, and the files that are generated by this file in the .cache directory are pages.json, sync-requires.js, async-requires.js, and data.json. In this section, we’ll walk through each of these files one by one.
Leave a Reply