-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.ts
40 lines (38 loc) · 1.22 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
import type { CreateWebpackConfigArgs } from 'gatsby'
import * as path from 'path'
export const onCreateWebpackConfig = ({ actions, getConfig, stage, loaders }: CreateWebpackConfigArgs) => {
actions.setWebpackConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'@components': path.resolve(__dirname, 'src/components'),
'@images': path.resolve(__dirname, 'src/images'),
'@pages': path.resolve(__dirname, 'src/pages'),
'@style': path.resolve(__dirname, 'src/style'),
'@static': path.resolve(__dirname, 'static')
}
}
})
if (stage === 'build-javascript') {
const config = getConfig()
const miniCssExtractPlugin = config.plugins.find(
(plugin: { constructor: { name: string } }) => plugin.constructor.name === 'MiniCssExtractPlugin'
)
if (miniCssExtractPlugin) {
miniCssExtractPlugin.options.ignoreOrder = true
}
actions.replaceWebpackConfig(config)
}
if (stage === 'build-html' || stage === 'develop-html') {
actions.setWebpackConfig({
module: {
rules: [
{
test: /(react-modal|react-intersection-observer)/,
use: loaders.null(),
},
],
},
})
}
}