-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-node.js
30 lines (30 loc) · 1.22 KB
/
gatsby-node.js
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
exports.onCreateWebpackConfig = ({ actions, loaders, getConfig }) => {
const config = getConfig()
config.module.rules = [
// Omit the default rule where test === '\.jsx?$'
...config.module.rules.filter(
rule => String(rule.test) !== String(/\.jsx?$/)
),
// Recreate it with custom exclude filter
{
// Called without any arguments, `loaders.js()` will return an
// object like:
// {
// options: undefined,
// loader: '/path/to/node_modules/gatsby/dist/utils/babel-loader.js',
// }
// Unless you're replacing Babel with a different transpiler, you probably
// want this so that Gatsby will apply its required Babel
// presets/plugins. This will also merge in your configuration from
// `babel.config.js`.
...loaders.js(),
test: /\.js$|jsx/,
// Exclude all node_modules from transpilation, except for 'swiper' and 'dom7'
exclude: modulePath =>
/node_modules/.test(modulePath) &&
!/node_modules\/(swiper|dom7)/.test(modulePath),
},
]
// This will completely replace the webpack config with the modified object.
actions.replaceWebpackConfig(config)
}