Add configuration and build changes
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -10,3 +10,5 @@ node_modules
|
|||||||
yarn-error.log
|
yarn-error.log
|
||||||
*.sublime-project
|
*.sublime-project
|
||||||
*.sublime-workspace
|
*.sublime-workspace
|
||||||
|
config/*.json
|
||||||
|
!config/template.json
|
||||||
|
3
config/template.json
Normal file
3
config/template.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"GA_SECRET": ""
|
||||||
|
}
|
@@ -1,15 +1,8 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
const withSass = require('@zeit/next-sass');
|
const withSass = require('@zeit/next-sass');
|
||||||
const withCSS = require('@zeit/next-css');
|
const withCSS = require('@zeit/next-css');
|
||||||
const rehypePrism = require('@mapbox/rehype-prism');
|
const rehypePrism = require('@mapbox/rehype-prism');
|
||||||
const {
|
|
||||||
getPageRoutes,
|
|
||||||
getGuideRoutes,
|
|
||||||
getRoadmapRoutes,
|
|
||||||
} = require("./scripts/path-map");
|
|
||||||
|
|
||||||
require('dotenv').config();
|
|
||||||
|
|
||||||
const withMDX = require('@next/mdx')({
|
const withMDX = require('@next/mdx')({
|
||||||
extension: /\.(md|mdx)?$/,
|
extension: /\.(md|mdx)?$/,
|
||||||
options: {
|
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 = {
|
const options = {
|
||||||
exportPathMap: () => {
|
exportPathMap: getPathMap(),
|
||||||
return {
|
env: loadConfig(process.env.NODE_ENV),
|
||||||
...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
|
|
||||||
pageExtensions: ['jsx', 'js', 'mdx', 'md'],
|
pageExtensions: ['jsx', 'js', 'mdx', 'md'],
|
||||||
|
|
||||||
webpack(config, options) {
|
webpack(config, options) {
|
||||||
// // Transforms SVGs to components
|
// // Transforms SVGs to components
|
||||||
config.module.rules.push({
|
config.module.rules.push({
|
||||||
@@ -58,7 +58,6 @@ const options = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
|
||||||
let nextConfig = withSass(options);
|
let nextConfig = withSass(options);
|
||||||
nextConfig = withCSS(nextConfig);
|
nextConfig = withCSS(nextConfig);
|
||||||
nextConfig = withMDX(nextConfig);
|
nextConfig = withMDX(nextConfig);
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"license": "BSD-4-Clause",
|
"license": "BSD-4-Clause",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next",
|
"dev": "NODE_ENV=dev next",
|
||||||
"html": "./scripts/build.sh",
|
"html": "./scripts/build.sh",
|
||||||
"serve:out": "serve out",
|
"serve:out": "serve out",
|
||||||
"sitemap": "node scripts/sitemap.js",
|
"sitemap": "node scripts/sitemap.js",
|
||||||
@@ -28,7 +28,6 @@
|
|||||||
"bootstrap": "^4.3.1",
|
"bootstrap": "^4.3.1",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"date-fns": "^2.6.0",
|
"date-fns": "^2.6.0",
|
||||||
"dotenv": "^8.2.0",
|
|
||||||
"font-awesome": "^4.7.0",
|
"font-awesome": "^4.7.0",
|
||||||
"next": "^9.0.4",
|
"next": "^9.0.4",
|
||||||
"node-sass": "^4.12.0",
|
"node-sass": "^4.12.0",
|
||||||
|
@@ -8,7 +8,7 @@ if [ ! -f "$ENV_FILE" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
next build
|
NODE_ENV=prod next build
|
||||||
next export
|
next export
|
||||||
echo 'roadmap.sh' > out/CNAME
|
echo 'roadmap.sh' > out/CNAME
|
||||||
touch out/.nojekyll
|
touch out/.nojekyll
|
||||||
|
@@ -80,8 +80,19 @@ const getRoadmapRoutes = () => {
|
|||||||
}, {});
|
}, {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the path-map understood by next.js
|
||||||
|
* @returns {{}}
|
||||||
|
*/
|
||||||
|
const getPathMap = () => () => ({
|
||||||
|
...getPageRoutes(),
|
||||||
|
...getGuideRoutes(),
|
||||||
|
...getRoadmapRoutes(),
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getPageRoutes,
|
getPageRoutes,
|
||||||
getGuideRoutes,
|
getGuideRoutes,
|
||||||
getRoadmapRoutes,
|
getRoadmapRoutes,
|
||||||
|
getPathMap,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user