@@ -2,22 +2,50 @@ const get = require('lodash/get')
22
33const NO_OP = ( ) => { }
44
5- let gatsbyNodeCustom
5+ const DEFAULT_RESOLVABLE_EXTENSIONS = ( ) => [ `.js` , `.jsx` ]
6+
7+ let gatsbyNodeCustom = { }
68try {
79 gatsbyNodeCustom = require ( './gatsby-node.custom' )
8- } catch ( err ) {
9- gatsbyNodeCustom = {
10- onCreateWebpackConfig : NO_OP ,
11- }
10+ } catch ( err ) { }
11+
12+ // https://www.gatsbyjs.org/docs/node-apis/
13+
14+ exports . createPages = args => {
15+ const createPages = get ( gatsbyNodeCustom , 'createPages' , NO_OP )
16+ return createPages ( args )
1217}
1318
14- exports . onCreateWebpackConfig = args => {
15- const onCreateWebpackConfig = get (
19+ exports . createPagesStatefully = args => {
20+ const createPagesStatefully = get (
1621 gatsbyNodeCustom ,
17- 'onCreateWebpackConfig' ,
22+ 'createPagesStatefully' ,
23+ NO_OP
24+ )
25+ return createPagesStatefully ( args )
26+ }
27+
28+ exports . createResolvers = args => {
29+ const createResolvers = get ( gatsbyNodeCustom , 'createResolvers' , NO_OP )
30+ return createResolvers ( args )
31+ }
32+
33+ exports . createSchemaCustomization = args => {
34+ const createSchemaCustomization = get (
35+ gatsbyNodeCustom ,
36+ 'createSchemaCustomization' ,
37+ NO_OP
38+ )
39+ return createSchemaCustomization ( args )
40+ }
41+
42+ exports . generateSideEffects = args => {
43+ const generateSideEffects = get (
44+ gatsbyNodeCustom ,
45+ 'generateSideEffects' ,
1846 NO_OP
1947 )
20- onCreateWebpackConfig ( args )
48+ return generateSideEffects ( args )
2149}
2250
2351exports . onCreateBabelConfig = args => {
@@ -26,5 +54,91 @@ exports.onCreateBabelConfig = args => {
2654 'onCreateBabelConfig' ,
2755 NO_OP
2856 )
29- onCreateBabelConfig ( args )
57+ return onCreateBabelConfig ( args )
58+ }
59+
60+ exports . onCreateDevServer = args => {
61+ const onCreateDevServer = get ( gatsbyNodeCustom , 'onCreateDevServer' , NO_OP )
62+ return onCreateDevServer ( args )
63+ }
64+
65+ exports . onCreateNode = args => {
66+ const onCreateNode = get ( gatsbyNodeCustom , 'onCreateNode' , NO_OP )
67+ return onCreateNode ( args )
68+ }
69+
70+ exports . onCreatePage = args => {
71+ const onCreatePage = get ( gatsbyNodeCustom , 'onCreatePage' , NO_OP )
72+ return onCreatePage ( args )
73+ }
74+
75+ exports . onCreateWebpackConfig = args => {
76+ const onCreateWebpackConfig = get (
77+ gatsbyNodeCustom ,
78+ 'onCreateWebpackConfig' ,
79+ NO_OP
80+ )
81+ return onCreateWebpackConfig ( args )
82+ }
83+
84+ exports . onPostBootstrap = args => {
85+ const onPostBootstrap = get ( gatsbyNodeCustom , 'onPostBootstrap' , NO_OP )
86+ return onPostBootstrap ( args )
87+ }
88+
89+ exports . onPostBuild = args => {
90+ const onPostBuild = get ( gatsbyNodeCustom , 'onPostBuild' , NO_OP )
91+ return onPostBuild ( args )
92+ }
93+
94+ exports . onPreBootstrap = args => {
95+ const onPreBootstrap = get ( gatsbyNodeCustom , 'onPreBootstrap' , NO_OP )
96+ return onPreBootstrap ( args )
97+ }
98+
99+ exports . onPreBuild = args => {
100+ const onPreBuild = get ( gatsbyNodeCustom , 'onPreBuild' , NO_OP )
101+ return onPreBuild ( args )
102+ }
103+
104+ exports . onPreExtractQueries = args => {
105+ const onPreExtractQueries = get (
106+ gatsbyNodeCustom ,
107+ 'onPreExtractQueries' ,
108+ NO_OP
109+ )
110+ return onPreExtractQueries ( args )
111+ }
112+
113+ exports . onPreInit = args => {
114+ const onPreInit = get ( gatsbyNodeCustom , 'onPreInit' , NO_OP )
115+ return onPreInit ( args )
116+ }
117+
118+ exports . preprocessSource = args => {
119+ const preprocessSource = get ( gatsbyNodeCustom , 'preprocessSource' , NO_OP )
120+ return preprocessSource ( args )
121+ }
122+
123+ exports . resolvableExtensions = args => {
124+ const resolvableExtensions = get (
125+ gatsbyNodeCustom ,
126+ 'resolvableExtensions' ,
127+ DEFAULT_RESOLVABLE_EXTENSIONS
128+ )
129+ return resolvableExtensions ( args )
130+ }
131+
132+ exports . setFieldsOnGraphQLNodeType = args => {
133+ const setFieldsOnGraphQLNodeType = get (
134+ gatsbyNodeCustom ,
135+ 'setFieldsOnGraphQLNodeType' ,
136+ ( ) => ( { } )
137+ )
138+ return setFieldsOnGraphQLNodeType ( args )
139+ }
140+
141+ exports . sourceNodes = args => {
142+ const sourceNodes = get ( gatsbyNodeCustom , 'sourceNodes' , NO_OP )
143+ return sourceNodes ( args )
30144}
0 commit comments