Skip to content

Commit a995ef6

Browse files
committed
Chore: Update environment variables and improve build configurations
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
1 parent 2aebed9 commit a995ef6

5 files changed

Lines changed: 38 additions & 9 deletions

File tree

.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
GATSBY_GRAPHQL_IDE=playground
1+
# GATSBY_GRAPHQL_IDE=playground

gatsby-config.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
/* eslint-env node */
22

3+
const isDevelopment = process.env.NODE_ENV === "development";
34
const isProduction = process.env.NODE_ENV === "production";
45
const isFullSiteBuild = process.env.BUILD_FULL_SITE === "true";
56
const HEAVY_COLLECTIONS = ["members", "integrations"];
67
const collectionIgnoreGlobs = isFullSiteBuild
78
? []
89
: HEAVY_COLLECTIONS.map((name) => `**/${name}/**`);
9-
// const isDevelopment = process.env.NODE_ENV === "development";
10+
const devFlags = isDevelopment
11+
? {
12+
PARALLEL_SOURCING: true,
13+
PRESERVE_FILE_DOWNLOAD_CACHE: true,
14+
PRESERVE_WEBPACK_CACHE: true,
15+
}
16+
: {};
1017

1118
module.exports = {
1219
siteMetadata: {
@@ -21,8 +28,8 @@ module.exports = {
2128
},
2229
flags: {
2330
FAST_DEV: true,
24-
PARALLEL_SOURCING: false, // Disable parallel sourcing to reduce memory pressure
2531
DEV_SSR: false,
32+
...devFlags,
2633
},
2734
trailingSlash: "never",
2835
plugins: [
@@ -518,4 +525,4 @@ module.exports = {
518525
"gatsby-plugin-meta-redirect",
519526
// make sure this is always the last one
520527
],
521-
};
528+
};

gatsby-node.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const slugify = require("./src/utils/slugify");
1111
const { paginate } = require("gatsby-awesome-pagination");
1212
const { createFilePath } = require("gatsby-source-filesystem");
1313
const config = require("./gatsby-config");
14+
const isDevelopment = process.env.NODE_ENV === "development";
15+
const isProduction = process.env.NODE_ENV === "production";
1416
const {
1517
componentsData,
1618
} = require("./src/sections/Projects/Sistent/components/content");
@@ -57,8 +59,16 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
5759
const { createPage } = actions;
5860

5961
const envCreatePage = (props) => {
62+
const pageConfig = { ...props };
63+
64+
if (isDevelopment) {
65+
pageConfig.defer = true;
66+
} else if (isProduction) {
67+
pageConfig.mode = "SSR";
68+
}
69+
6070
if (process.env.CI === "true") {
61-
const { path, matchPath, ...rest } = props;
71+
const { path, matchPath, ...rest } = pageConfig;
6272

6373
createRedirect({
6474
fromPath: `/${path}/`,
@@ -73,7 +83,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
7383
...rest,
7484
});
7585
}
76-
return createPage(props);
86+
return createPage(pageConfig);
7787
};
7888

7989
const blogPostTemplate = path.resolve("src/templates/blog-single.js");
@@ -537,7 +547,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
537547
});
538548
};
539549

540-
createComponentPages(createPage, components);
550+
createComponentPages(envCreatePage, components);
541551
};
542552

543553
// slug starts and ends with '/' so parts[0] and parts[-1] will be empty

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"url": "https://layer5.io"
1111
},
1212
"scripts": {
13-
"build": "cross-env BUILD_FULL_SITE=true NODE_OPTIONS=--max-old-space-size=16384 gatsby build",
13+
"build": "cross-env BUILD_FULL_SITE=true NODE_OPTIONS=--max-old-space-size=8192 gatsby build",
1414
"clean": "gatsby clean && rimraf node_modules",
15-
"develop": "cross-env BUILD_FULL_SITE=true NODE_OPTIONS=--max-old-space-size=16384 env-cmd -f .env.development gatsby develop",
15+
"develop": "cross-env BUILD_FULL_SITE=true NODE_OPTIONS=--max-old-space-size=8192 env-cmd -f .env.development gatsby develop",
1616
"develop:lite": "cross-env BUILD_FULL_SITE=false NODE_OPTIONS=--max-old-space-size=8192 env-cmd -f .env.development gatsby develop",
1717
"dev": "npm run develop",
1818
"start": "npm run develop",

src/sections/Learn-Layer5/Chapters/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ const Chapters = ({ chapterData, courseData, location, serviceMeshesList, TOCDat
7070
const findServiceMeshImage = (images, serviceMesh) => images.find(image => image.name.toLowerCase() == serviceMesh);
7171
const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
7272

73+
const missingServiceMeshImages = availableServiceMeshesArray
74+
.filter(({ section }) => {
75+
const meshImage = findServiceMeshImage(serviceMeshImages, section);
76+
return !(meshImage && meshImage.imagepath?.childImageSharp?.gatsbyImageData);
77+
})
78+
.map(({ section }) => section);
79+
80+
if (missingServiceMeshImages.length > 0) {
81+
const context = chapterData?.fields?.slug || "unknown-chapter";
82+
throw new Error(`[Chapters] Missing meshesYouLearn image data for: ${missingServiceMeshImages.join(", ")} (chapter: ${context}).`);
83+
}
84+
7385
const ServiceMeshesAvailable = ({ serviceMeshes }) => serviceMeshes.map((sm, index) => {
7486
return (
7587
<>

0 commit comments

Comments
 (0)