generated from vtex-sites/base.store
-
Notifications
You must be signed in to change notification settings - Fork 14
/
gatsby-node.ts
60 lines (53 loc) · 1.38 KB
/
gatsby-node.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import type { GatsbyNode } from 'gatsby'
import { apiSchema } from './src/server'
export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] = ({
actions: { setWebpackConfig },
stage,
}) => {
const isProfilingEnabled = process.env.GATSBY_STORE_PROFILING === 'true'
if (stage === 'build-javascript') {
if (isProfilingEnabled) {
setWebpackConfig({
optimization: {
minimize: false,
moduleIds: 'named',
chunkIds: 'named',
concatenateModules: false,
},
})
} else {
setWebpackConfig({
optimization: {
runtimeChunk: {
name: `webpack-runtime`,
},
splitChunks: {
name: false,
cacheGroups: {
styles: {
name: `styles`,
test: /\.(css|scss)$/,
chunks: `initial`,
enforce: true,
},
},
},
},
})
}
}
}
export const onCreateBabelConfig: GatsbyNode['onCreateBabelConfig'] = ({
actions,
}) => {
actions.setBabelPlugin({
name: `@faststore/graphql-utils/babel`,
options: {},
})
}
export const createSchemaCustomization: GatsbyNode['createSchemaCustomization'] =
async (gatsbyApi) => {
const { actions } = gatsbyApi
const schema = await apiSchema
actions.addThirdPartySchema({ schema })
}