Add configuration and build changes
This commit is contained in:
@@ -1,15 +1,8 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const withSass = require('@zeit/next-sass');
|
||||
const withCSS = require('@zeit/next-css');
|
||||
const rehypePrism = require('@mapbox/rehype-prism');
|
||||
const {
|
||||
getPageRoutes,
|
||||
getGuideRoutes,
|
||||
getRoadmapRoutes,
|
||||
} = require("./scripts/path-map");
|
||||
|
||||
require('dotenv').config();
|
||||
|
||||
const withMDX = require('@next/mdx')({
|
||||
extension: /\.(md|mdx)?$/,
|
||||
options: {
|
||||
@@ -17,23 +10,30 @@ const withMDX = require('@next/mdx')({
|
||||
},
|
||||
});
|
||||
|
||||
const { getPathMap } = require("./scripts/path-map");
|
||||
|
||||
/**
|
||||
* Loads the configuration for the given environment
|
||||
* @param env
|
||||
* @returns {*}
|
||||
*/
|
||||
const loadConfig = (env = 'dev') => {
|
||||
const configPath = `./config/${env}.json`;
|
||||
if (!fs.existsSync(configPath)) {
|
||||
console.log(`Config file not found: ${configPath}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`Config file found: ${configPath}`);
|
||||
|
||||
// @todo stringify the values for webpack - it doesn't understand objects
|
||||
return require(configPath);
|
||||
};
|
||||
|
||||
const options = {
|
||||
exportPathMap: () => {
|
||||
return {
|
||||
...getPageRoutes(),
|
||||
...getGuideRoutes(),
|
||||
...getRoadmapRoutes(),
|
||||
};
|
||||
},
|
||||
|
||||
// @todo read these from `process.env` and inject without having to write the vars here
|
||||
env: {
|
||||
GA_SECRET: process.env.GA_SECRET
|
||||
},
|
||||
|
||||
// Allow mdx and md files to be pages
|
||||
exportPathMap: getPathMap(),
|
||||
env: loadConfig(process.env.NODE_ENV),
|
||||
pageExtensions: ['jsx', 'js', 'mdx', 'md'],
|
||||
|
||||
webpack(config, options) {
|
||||
// // Transforms SVGs to components
|
||||
config.module.rules.push({
|
||||
@@ -58,7 +58,6 @@ const options = {
|
||||
},
|
||||
};
|
||||
|
||||
//
|
||||
let nextConfig = withSass(options);
|
||||
nextConfig = withCSS(nextConfig);
|
||||
nextConfig = withMDX(nextConfig);
|
||||
|
Reference in New Issue
Block a user