forked from phork/phorkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-node.js
64 lines (58 loc) · 1.7 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const path = require('path');
const src = path.resolve(__dirname, '../src');
exports.onCreateWebpackConfig = ({ actions, loaders }) => {
actions.setWebpackConfig({
module: {
rules: [
{
exclude: [
path.join(src, '**/stories/*'),
path.resolve(__dirname, '.storybook'),
path.resolve(__dirname, 'node_modules/@storybook'),
],
},
{
// this seems like a rather heavy-handed approach but it works as a temporary fix
test: src => src.includes('storybook'),
use: loaders.null(),
},
],
},
resolve: {
modules: [src, 'node_modules'],
alias: {
components$: path.join(src, 'components'),
compositions$: path.join(src, 'compositions'),
config$: path.join(src, 'config'),
context$: path.join(src, 'context'),
docs$: path.join(src, 'docs'),
hooks$: path.join(src, 'hooks'),
icons$: path.join(src, 'icons'),
postcss$: path.join(src, 'postcss/vars/index'),
public$: path.resolve(__dirname, '../public'),
styles$: path.join(src, 'styles'),
types$: path.join(src, 'types'),
utils$: path.join(src, 'utils'),
...(process.env.NODE_ENV === 'development'
? {
'react-dom': '@hot-loader/react-dom',
}
: {}),
},
},
});
};
exports.onCreateBabelConfig = ({ actions }) => {
actions.setBabelPlugin({
name: '@babel/plugin-proposal-object-rest-spread',
});
actions.setBabelPlugin({
name: '@emotion/babel-plugin',
});
actions.setBabelPreset({
name: `babel-preset-gatsby`,
options: {
reactRuntime: 'classic',
},
});
};