-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
56 lines (44 loc) · 1.14 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
52
53
54
55
56
const path = require('path');
const fs = require('fs');
const rehypePrism = require('@mapbox/rehype-prism');
/**
* Loads the configuration for the given environment
* @param env
* @returns {*}
*/
const loadConfig = (env = 'dev') => {
const configPath = `./config/${env}.json`;
if (!fs.existsSync(configPath)) {
console.warn(`Config file not found: ${configPath}. Using environment variables only.`);
}
const appConfig = {};
for (let key in process.env) {
if (!key.startsWith('ROADMAP_')) {
continue;
}
appConfig[key.replace('ROADMAP_', '')] = process.env[key];
}
return appConfig;
};
const withMDX = require('@next/mdx')({
extension: /\.(md|mdx)?$/,
options: {
rehypePlugins: [rehypePrism]
}
});
let nextConfig = {
reactStrictMode: true,
poweredByHeader: false,
env: loadConfig(process.env.NODE_ENV),
webpack(config, options) {
config.resolve.modules.push(path.resolve('./'));
// Transforms SVGs to components
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack']
});
return config;
}
};
nextConfig = withMDX(nextConfig);
module.exports = nextConfig;