Loading Configured Plugins

Among the very first steps performed in Gatsby’s bootstrap is loading all the plugins configured in gatsby-config.js, as well as internal Gatsby plugins that come with the core framework. Gatsby saves these loaded plugins to Redux using the flattened​Plu⁠gins namespace. In Redux, each plugin has the fields listed in Table 14-1.

NOTE

For more information about how Gatsby leverages Redux for data storage, consult the Gatsby documentation’s guide to data storage in Redux.

FieldDescription
resolveThe absolute path to the plugin’s directory
idA concatenated string consisting of Plugin and a space followed by the name of the plugin; e.g., Plugin my-plugin
nameThe name of the plugin; e.g., my-plugin
versionThe version according to the plugin definition in package.json; if the plugin is a local plugin, one is generated from the file’s hash
pluginOptionsThe plugin options as configured in gatsby-config.js
nodeAPIsThe list of Gatsby Node APIs implemented by the plugin, e.g., [`sourceNodes`, `onCrea⁠te​Node` ...]
browserAPIsThe list of Gatsby Browser APIs implemented by the plugin
ssrAPIsThe list of Gatsby SSR APIs implemented by the plugin

To view the Gatsby codebase itself, you can look at the GitHub repository, clone the Gatsby framework, or open node_modules/gatsby in any existing Gatsby project. The logic governing this portion of the Gatsby bootstrap can be found in the Gatsby framework within the src/bootstrap/load-plugins directory, where validate.js performs a lookup from each of the Gatsby APIs implemented by the plugins and saves the lookup result to Redux under api-to-plugins.


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *