permalink https://github.com/gatsbyjs/gatsby/blob/ffd8b2d691c995c760fe380769852bcdb26a2278/packages/gatsby/src/bootstrap/index.js
- open and validate gatsby-config (get-config-file.js) 1.5 load themes (swyx added this note July 2019)
- load plugins (load-plugins/index.js) from the list given in
gatsby-config.js
- onPreBootstrap: runs
onPreBootstrap
if 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
/public
directory) - a simple delete - delete
/.cache
if hash ofpackage.json
,gatsby-config.js
,gatsby-node.js
, andplugin versions
has changed. then init or reuse/.cache/cache
. - copy gatsby files from the
cache-dir
folder in the main gatsby package into your new/.cache
. Make sure./cache/json
exists and./cache/fragments
is empty. If your plugins implementgatsby-browser
andgatsby-ssr
, write them out to.cache/api-runner-browser-plugins.js
and.cache/api-runner-ssr.js
. - source and transform nodes: run
sourceNodes
if implemented by plugins (eg gatsby-source-wikipedia), then garbage collect stale nodes
onCreateNode
runs whenever thecreateNode
action is called (which dispatchesCREATE_NODE
)
- building schema: runs schema/index.js to build everything involved in the
RootQueryType
GraphQLSchema. a lot of code here i'm skipping over. - add extensions: by default gatsby handles
.js
and.jsx
, but plugins can implementresolvableExtensions
to add filetypes for other languages, eg gatsby-plugin-typescript - createPages: run
createPages
hooks implemented by your plugins (e.g. page-hot-reloader) and yourgatsby-node.js
onCreatePage
runs whenever thecreatePage
action 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
onPreExtractQueries
hook 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.