-
Notifications
You must be signed in to change notification settings - Fork 16
/
gatsby-node.js
39 lines (33 loc) · 850 Bytes
/
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
const path = require('path');
require('dotenv').config({
path: '.env',
});
exports.onCreateWebpackConfig = function addPathMapping({
stage,
actions,
getConfig,
}) {
actions.setWebpackConfig({
resolve: {
alias: {
'~': path.resolve(__dirname, 'src'),
},
},
});
// Attempt to improve webpack vender code splitting
if (stage === 'build-javascript') {
const config = getConfig();
config.optimization.splitChunks.cacheGroups = {
...config.optimization.splitChunks.cacheGroups,
vendors: {
test: /[\\/]node_modules[\\/]/,
enforce: true,
chunks: 'all',
priority: 1,
},
};
// Ensure Gatsby does not do any css code splitting
config.optimization.splitChunks.cacheGroups.styles.priority = 10;
actions.replaceWebpackConfig(config);
}
};