1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-02-23 19:13:19 +01:00
developer-roadmap/next.config.js

68 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-08-20 15:55:39 +02:00
const path = require('path');
2021-09-05 20:38:08 +02:00
const fs = require('fs');
2021-08-20 15:55:39 +02:00
const rehypePrism = require('@mapbox/rehype-prism');
2021-09-05 20:38:08 +02:00
/**
* 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;
};
2021-08-20 15:55:39 +02:00
const withMDX = require('@next/mdx')({
extension: /\.(md|mdx)?$/,
options: {
rehypePlugins: [rehypePrism]
}
});
let nextConfig = {
2021-08-01 13:08:35 +02:00
reactStrictMode: true,
2021-08-19 15:01:18 +02:00
poweredByHeader: false,
2021-09-05 20:38:08 +02:00
env: loadConfig(process.env.NODE_ENV),
2021-08-20 15:55:39 +02:00
webpack(config, options) {
config.resolve.modules.push(path.resolve('./'));
2021-08-20 17:06:26 +02:00
// Transforms SVGs to components
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack']
});
2021-08-20 15:55:39 +02:00
return config;
2022-08-31 11:31:25 +04:00
},
async redirects() {
return [
{
source: '/node.js',
destination: '/nodejs',
permanent: true,
},
]
},
2021-08-20 15:55:39 +02:00
};
nextConfig = withMDX(nextConfig);
module.exports = nextConfig;