-
Notifications
You must be signed in to change notification settings - Fork 21
/
gatsby-node.js
47 lines (47 loc) · 1.42 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
exports.onCreateWebpackConfig = ({
stage, loaders, rules, actions, getConfig
}) => {
if (stage.startsWith('develop')) {
// actions.setWebpackConfig({
// resolve: {
// alias: {
// 'react-dom': '@hot-loader/react-dom'
// }
// }
// });
}
const isSSR = stage.includes('html');
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`.
...rules.js(),
// test: /\.jsx?$/,
// Exclude all node_modules from transpilation, except for 'swiper' and 'dom7'
exclude: (modulePath) => /node_modules/.test(modulePath)
},
{
test: /pikaday/,
use: loaders.null()
}
];
// config.resolve = {
// ...config.resolve,
// //symlinks: !isSSR
// };
actions.replaceWebpackConfig(config);
};