-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgatsby-node.js
39 lines (30 loc) · 991 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');
const { appLocales } = require('./src/i18n');
exports.onCreatePage = async ({ page, actions }) => {
const { createPage, deletePage } = actions;
const newPage = page;
deletePage(page);
Object.keys(appLocales).forEach(locale => {
newPage.context = { locale };
newPage.path = appLocales[locale].default
? page.path
: appLocales[locale].path + page.path;
createPage(newPage);
});
};
exports.onCreateWebpackConfig = ({ actions, getConfig }) => {
actions.setWebpackConfig({
resolve: {
alias: {
'styled-components': path.resolve('./node_modules/styled-components'),
},
},
});
const webpackConfig = getConfig();
delete webpackConfig.resolve.alias['core-js'];
webpackConfig.resolve.modules = [
path.resolve(__dirname, 'node_modules/gatsby/node_modules'), // for Gatsby's core-js@2
'node_modules', // your modules w/ core-js@3
];
actions.replaceWebpackConfig(webpackConfig);
};