-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
51 lines (48 loc) · 1.49 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
const path = require('path');
// const withTM = require('next-transpile-modules')(['d3-fetch']);
function generateIncludes(modules) {
return [
new RegExp(`(${modules.join('|')})$`),
new RegExp(`(${modules.join('|')})/(?!.*node_modules)`),
];
}
const includes = generateIncludes(['d3', 'd3-dsv', 'd3-fetch']);
module.exports = (phase, { defaultConfig }) => {
const dms = process.env.DMS;
const cms = process.env.CMS;
if (phase === PHASE_DEVELOPMENT_SERVER) {
if (dms) {
console.log('\nYou are running the app in dev mode');
console.log('Happy coding ☀️\n');
}
}
return {
...defaultConfig,
webpack: (config, options) => {
config.externals = config.externals.map((external) => {
if (typeof external !== 'function') return external;
return (context, request, callback) => {
return includes.find((i) =>
i.test(
request.startsWith('.')
? path.resolve(context, request)
: request
)
)
? callback() // i.e., not an external
: external(context, request, callback);
};
});
return config;
},
i18n: {
locales: ['en', 'fr', 'nl-NL', 'te'],
defaultLocale: 'en',
},
publicRuntimeConfig: {
DMS: dms ? dms.replace(/\/?$/, '') : 'https://demo.ckan.org',
CMS: cms ? cms.replace(/\/?$/, '') : 'oddk.home.blog',
},
};
};