Skip to content

Commit 38f7413

Browse files
committed
Chore: Implement lightweight build mode for local development
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
1 parent e920c63 commit 38f7413

7 files changed

Lines changed: 284 additions & 109 deletions

File tree

Makefile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,19 @@ setup-libs:
2121
setup:
2222
npm install --legacy-peer-deps
2323

24-
## Run layer5.io on your local machine.
24+
25+
# "make site" - The default lightweight build keeps the dev server fast by skipping heavy collections.
26+
## Run a partial build of layer5.io on your local machine.
2527
site:
26-
npm start
27-
28+
@echo "🏗️ Building lightweight site version (excluding Members and Integrations collections)..."
29+
@npm run develop:lite
30+
31+
# "make site-full" forces the dev server to include every collection.
32+
## Run a full build of layer5.io on your local machine.
33+
site-full:
34+
@echo "🏗️ Building full site version (including Members and Integrations collections)..."
35+
@npm run develop
36+
2837
## Run layer5.io on your local machine. Alternate method.
2938
site-fast:
3039
NODE_OPTIONS=--max-old-space-size=8192 gatsby develop
@@ -51,4 +60,4 @@ features:
5160
node .github/build/features-to-json.js .github/build/spreadsheet.csv src/sections/Pricing/feature_data.json
5261
rm .github/build/spreadsheet.csv
5362

54-
.PHONY: setup build site clean site-fast lint features
63+
.PHONY: setup build site site-full clean site-fast lint features

gatsby-config.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
/* eslint-env node */
22

33
const isProduction = process.env.NODE_ENV === "production";
4+
const isFullSiteBuild = process.env.BUILD_FULL_SITE !== "false";
5+
const HEAVY_COLLECTIONS = ["members", "integrations"];
6+
const collectionIgnoreGlobs = isFullSiteBuild
7+
? []
8+
: HEAVY_COLLECTIONS.map((name) => `**/${name}/**`);
49
// const isDevelopment = process.env.NODE_ENV === "development";
510

611
module.exports = {
@@ -449,10 +454,7 @@ module.exports = {
449454
options: {
450455
path: `${__dirname}/src/collections`,
451456
name: "collections",
452-
ignore: [
453-
// eslint-disable-next-line quotes
454-
`src/collections/integrations/**`,
455-
],
457+
ignore: collectionIgnoreGlobs,
456458
},
457459
},
458460
{

gatsby-node.js

Lines changed: 158 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ const {
1515
componentsData,
1616
} = require("./src/sections/Projects/Sistent/components/content");
1717

18+
const HEAVY_COLLECTIONS = new Set(["members", "integrations"]);
19+
const isFullSiteBuild = process.env.BUILD_FULL_SITE !== "false";
20+
const shouldIncludeCollection = (collection) => isFullSiteBuild || !HEAVY_COLLECTIONS.has(collection);
21+
1822
if (process.env.CI === "true") {
1923
// All process.env.CI conditionals in this file are in place for GitHub Pages, if webhost changes in the future, code may need to be modified or removed.
2024
//Replacing '/' would result in empty string which is invalid
@@ -105,6 +109,31 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
105109
const resourcePostTemplate = path.resolve("src/templates/resource-single.js");
106110
const integrationTemplate = path.resolve("src/templates/integrations.js");
107111

112+
const memberBioQuery = isFullSiteBuild
113+
? `
114+
memberBio: allMdx(
115+
filter: {
116+
fields: { collection: { eq: "members" } }
117+
frontmatter: { published: { eq: true }, executive_bio: { eq: true } }
118+
}
119+
) {
120+
nodes {
121+
frontmatter {
122+
name
123+
permalink
124+
}
125+
fields {
126+
slug
127+
collection
128+
}
129+
internal {
130+
contentFilePath
131+
}
132+
}
133+
}
134+
`
135+
: "";
136+
108137
const res = await graphql(`
109138
{
110139
allPosts: allMdx(filter: { frontmatter: { published: { eq: true } } }) {
@@ -148,26 +177,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
148177
fieldValue
149178
}
150179
}
151-
memberBio: allMdx(
152-
filter: {
153-
fields: { collection: { eq: "members" } }
154-
frontmatter: { published: { eq: true }, executive_bio: { eq: true } }
155-
}
156-
) {
157-
nodes {
158-
frontmatter {
159-
name
160-
permalink
161-
}
162-
fields {
163-
slug
164-
collection
165-
}
166-
internal {
167-
contentFilePath
168-
}
169-
}
170-
}
180+
${memberBioQuery}
171181
singleWorkshop: allMdx(
172182
filter: { fields: { collection: { eq: "workshops" } } }
173183
) {
@@ -223,35 +233,22 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
223233

224234
const allNodes = res.data.allPosts.nodes;
225235

226-
const blogs = allNodes.filter((node) => node.fields.collection === "blog");
227-
228-
const resources = allNodes.filter(
229-
(node) => node.fields.collection === "resources"
230-
);
231-
232-
const news = allNodes.filter((node) => node.fields.collection === "news");
233-
234-
const books = allNodes.filter(
235-
(node) => node.fields.collection === "service-mesh-books"
236-
);
237-
238-
const events = allNodes.filter((node) => node.fields.collection === "events");
239-
240-
const programs = allNodes.filter(
241-
(node) => node.fields.collection === "programs"
242-
);
243-
244-
const careers = allNodes.filter(
245-
(node) => node.fields.collection === "careers"
246-
);
247-
248-
const members = allNodes.filter(
249-
(node) => node.fields.collection === "members"
250-
);
236+
const filterByCollection = (collection) => {
237+
if (!shouldIncludeCollection(collection)) {
238+
return [];
239+
}
240+
return allNodes.filter((node) => node.fields.collection === collection);
241+
};
251242

252-
const integrations = allNodes.filter(
253-
(nodes) => nodes.fields.collection === "integrations"
254-
);
243+
const blogs = filterByCollection("blog");
244+
const resources = filterByCollection("resources");
245+
const news = filterByCollection("news");
246+
const books = filterByCollection("service-mesh-books");
247+
const events = filterByCollection("events");
248+
const programs = filterByCollection("programs");
249+
const careers = filterByCollection("careers");
250+
const members = filterByCollection("members");
251+
const integrations = filterByCollection("integrations");
255252

256253
const singleWorkshop = res.data.singleWorkshop.nodes;
257254
const labs = res.data.labs.nodes;
@@ -356,26 +353,30 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
356353
});
357354
});
358355

359-
members.forEach((member) => {
360-
envCreatePage({
361-
path: member.fields.slug,
362-
component: `${MemberTemplate}?__contentFilePath=${member.internal.contentFilePath}`,
363-
context: {
364-
slug: member.fields.slug,
365-
},
356+
if (isFullSiteBuild) {
357+
members.forEach((member) => {
358+
envCreatePage({
359+
path: member.fields.slug,
360+
component: `${MemberTemplate}?__contentFilePath=${member.internal.contentFilePath}`,
361+
context: {
362+
slug: member.fields.slug,
363+
},
364+
});
366365
});
367-
});
366+
}
368367

369-
const MemberBio = res.data.memberBio.nodes;
370-
MemberBio.forEach((memberbio) => {
371-
envCreatePage({
372-
path: `${memberbio.fields.slug}/bio`,
373-
component: `${MemberBioTemplate}?__contentFilePath=${memberbio.internal.contentFilePath}`,
374-
context: {
375-
member: memberbio.frontmatter.name,
376-
},
368+
const MemberBio = res.data.memberBio?.nodes || [];
369+
if (isFullSiteBuild) {
370+
MemberBio.forEach((memberbio) => {
371+
envCreatePage({
372+
path: `${memberbio.fields.slug}/bio`,
373+
component: `${MemberBioTemplate}?__contentFilePath=${memberbio.internal.contentFilePath}`,
374+
context: {
375+
member: memberbio.frontmatter.name,
376+
},
377+
});
377378
});
378-
});
379+
}
379380

380381
singleWorkshop.forEach((workshop) => {
381382
envCreatePage({
@@ -397,16 +398,18 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
397398
});
398399
});
399400

400-
integrations.forEach((integration) => {
401-
envCreatePage({
402-
path: `/cloud-native-management/meshery${integration.fields.slug}`,
403-
component: `${integrationTemplate}?__contentFilePath=${integration.internal.contentFilePath}`,
404-
context: {
405-
slug: integration.fields.slug,
406-
name: "_images/" + integration.fields.slug.split("/")[2],
407-
},
401+
if (isFullSiteBuild) {
402+
integrations.forEach((integration) => {
403+
envCreatePage({
404+
path: `/cloud-native-management/meshery${integration.fields.slug}`,
405+
component: `${integrationTemplate}?__contentFilePath=${integration.internal.contentFilePath}`,
406+
context: {
407+
slug: integration.fields.slug,
408+
name: "_images/" + integration.fields.slug.split("/")[2],
409+
},
410+
});
408411
});
409-
});
412+
}
410413

411414
programs.forEach((program) => {
412415
envCreatePage({
@@ -418,6 +421,35 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
418421
});
419422
});
420423

424+
if (!isFullSiteBuild) {
425+
const placeholderPages = [
426+
{
427+
path: "/__placeholders/integration",
428+
component: integrationTemplate,
429+
context: {
430+
slug: "/integrations/__placeholder__",
431+
name: "__placeholder__",
432+
},
433+
},
434+
{
435+
path: "/__placeholders/member",
436+
component: MemberTemplate,
437+
context: {
438+
slug: "/members/__placeholder__",
439+
},
440+
},
441+
{
442+
path: "/__placeholders/executive-bio",
443+
component: MemberBioTemplate,
444+
context: {
445+
member: "__placeholder__",
446+
},
447+
},
448+
];
449+
450+
placeholderPages.forEach((page) => envCreatePage(page));
451+
}
452+
421453
const learnNodes = res.data.learncontent.nodes;
422454

423455
learnNodes.forEach((node) => {
@@ -753,26 +785,60 @@ exports.createSchemaCustomization = ({ actions }) => {
753785
type Mdx implements Node {
754786
frontmatter: Frontmatter
755787
}
788+
789+
type FrontmatterComponent {
790+
name: String
791+
description: String
792+
colorIcon: File @fileByRelativePath
793+
whiteIcon: File @fileByRelativePath
794+
}
795+
756796
type Frontmatter {
757-
subtitle: String,
758-
abstract: String,
759-
eurl: String,
760-
twitter: String,
761-
github: String,
762-
layer5: String,
763-
meshmate: String,
764-
maintainer:String,
765-
emeritus: String,
766-
link: String,
767-
labs: String,
768-
slides: String,
769-
slack: String,
770-
video: String,
771-
community_manager: String,
772-
docURL: String,
773-
permalink: String,
774-
slug: String,
797+
title: String
798+
subtitle: String
799+
abstract: String
800+
description: String
801+
eurl: String
802+
twitter: String
803+
github: String
804+
layer5: String
805+
meshmate: String
806+
maintainer: String
807+
emeritus: String
808+
link: String
809+
labs: String
810+
slides: String
811+
slack: String
812+
video: String
813+
community_manager: String
814+
docURL: String
815+
permalink: String
816+
slug: String
775817
redirect_from: [String]
818+
category: String
819+
subcategory: String
820+
registrant: String
821+
featureList: [String]
822+
howItWorks: String
823+
howItWorksDetails: String
824+
components: [FrontmatterComponent]
825+
integrationIcon: File @fileByRelativePath
826+
darkModeIntegrationIcon: File @fileByRelativePath
827+
workingSlides: [File] @fileByRelativePath
828+
name: String
829+
position: String
830+
email: String
831+
profile: String
832+
linkedin: String
833+
location: String
834+
badges: [String]
835+
status: String
836+
bio: String
837+
executive_bio: String
838+
executive_position: String
839+
company: String
840+
executive_image: File @fileByRelativePath
841+
image_path: File @fileByRelativePath
776842
}
777843
`;
778844
createTypes(typeDefs);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Layer5",
2+
"name": "layer5",
33
"description": "Our cloud native application and infrastructure management software enables organizations to expect more from their infrastructure. At Layer5, we believe collaboration enables innovation, and infrastructure enables collaboration",
44
"version": "1.0.0",
55
"private": true,
@@ -13,6 +13,7 @@
1313
"build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 gatsby build",
1414
"clean": "gatsby clean && rimraf node_modules",
1515
"develop": "cross-env NODE_OPTIONS=--max-old-space-size=8192 env-cmd -f .env.development gatsby develop",
16+
"develop:lite": "cross-env BUILD_FULL_SITE=false NODE_OPTIONS=--max-old-space-size=8192 env-cmd -f .env.development gatsby develop",
1617
"dev": "npm run develop",
1718
"start": "npm run develop",
1819
"serve": "gatsby serve",

0 commit comments

Comments
 (0)