forked from bestofjs/javascript-risingstars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
34 lines (30 loc) · 973 Bytes
/
next.config.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
const settings = require("./data/settings.json");
module.exports = {
async redirects() {
const yearRedirects = settings.map(({ year }) => ({
source: `/${year}`,
destination: `/${year}/en`,
permanent: true,
}));
const currentYear = settings.find(({ current }) => !!current).year;
const rootRedirect = {
source: "/",
destination: `/${currentYear}/en`,
permanent: true,
};
return [rootRedirect, ...yearRedirects];
},
// Hack to avoid errors like `Module not found: Can't resolve 'fs'`
// when using helper functions that include backend code from pages
// see https://github.com/vercel/next.js/issues/16153#issuecomment-976216790
// and https://github.com/vercel/next.js/issues/27741#issuecomment-919827714
webpack: (config, { webpack, isServer }) => {
config.externals = config.externals.concat([
"flat",
"fs-extra",
"jdown",
"path",
]);
return config;
},
};