permalink https://github.com/gatsbyjs/gatsby/blob/ffd8b2d691c995c760fe380769852bcdb26a2278/packages/gatsby/src/bootstrap/index.js
- open and validate gatsby-config (get-config-file.js)
- load plugins (load-plugins/index.js) from the list given in
gatsby-config.js - onPreBootstrap: runs
onPreBootstrapif it is implemented in any plugins, for example gatsby-plugin-typography. Receives handy apiCallArgs and pluginOptions. - delete html and css files from previous builds (from the
/publicdirectory) - a simple delete - delete
/.cacheif hash ofpackage.json,gatsby-config.js,gatsby-node.js, andplugin versionshas changed. then init or reuse/.cache/cache. - copy gatsby files from the
cache-dirfolder in the main gatsby package into your new/.cache. Make sure./cache/jsonexists and./cache/fragmentsis empty. If your plugins implementgatsby-browserandgatsby-ssr, write them out to.cache/api-runner-browser-plugins.jsand.cache/api-runner-ssr.js. - source and transform nodes: run
sourceNodesif implemented by plugins (eg gatsby-source-wikipedia), then garbage collect stale nodes
onCreateNoderuns whenever thecreateNodeaction is called (which dispatchesCREATE_NODE)
- building schema: runs schema/index.js to build everything involved in the
RootQueryTypeGraphQLSchema. a lot of code here i'm skipping over. - add extensions: by default gatsby handles
.jsand.jsx, but plugins can implementresolvableExtensionsto add filetypes for other languages, eg gatsby-plugin-typescript - createPages: run
createPageshooks implemented by your plugins (e.g. page-hot-reloader) and yourgatsby-node.js
onCreatePageruns whenever thecreatePageaction is called (which dispatchesCREATE_PAGE)
- createPagesStatefully: "A variant on createPages for plugins that want to have full control over adding/removing pages." more here.
- onPreExtractQueries: runs the
onPreExtractQuerieshook for plugins like gatsby-transformer-sharp and gatsby-source-contentful. - update schema: run schema AGAIN! (why? the comment says "Update Schema for SitePage."). Report conflicting field types.
- extract queries from components: starting from query-watcher.js, use queryCompiler to either replaceComponentQuery for pages or replaceStaticQuery for staticQueries.
- (if not in
NODE_ENV != production) start the createPages page-hot-reloader - run graphql queries: runQueriesForPathnames for pageQueries and staticQueries.
- write out page data: writePages!
- write out redirect data: writes out browser redirects to
.cache/redirects.json - bootstrap finished - ${process.uptime()}s: yay
- onPostBootstrap: calls "onPostBootstrap" hook, but no packages seem to implement it.