Skip to content

Commit

Permalink
quiet down spa creation tool (#3094)
Browse files Browse the repository at this point in the history
* quiet down spa creation tool

* wording
  • Loading branch information
peterbe authored Mar 2, 2021
1 parent 05d136d commit e58786c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions build/spas.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ const { getFeedEntries } = require("./feedparser");
const { renderHTML } = require("../ssr/dist/main");

async function buildSPAs(options) {
let buildCount = 0;

// The URL isn't very important as long as it triggers the right route in the <App/>
const url = "/en-US/404.html";
const html = renderHTML(url, { pageNotFound: true });
const outPath = path.join(BUILD_OUT_ROOT, "en-us", "_spas");
fs.mkdirSync(outPath, { recursive: true });
fs.writeFileSync(path.join(outPath, path.basename(url)), html);
if (!options.quiet) {
buildCount++;
if (options.verbose) {
console.log("Wrote", path.join(outPath, path.basename(url)));
}

Expand All @@ -38,7 +41,8 @@ async function buildSPAs(options) {
fs.mkdirSync(outPath, { recursive: true });
const filePath = path.join(outPath, "index.html");
fs.writeFileSync(filePath, html);
if (!options.quiet) {
buildCount++;
if (options.verbose) {
console.log("Wrote", filePath);
}
}
Expand Down Expand Up @@ -76,18 +80,23 @@ async function buildSPAs(options) {
fs.mkdirSync(outPath, { recursive: true });
const filePath = path.join(outPath, "index.html");
fs.writeFileSync(filePath, html);
if (!options.quiet) {
buildCount++;
if (options.verbose) {
console.log("Wrote", filePath);
}
// Also, dump the feed entries as a JSON file so the data can be gotten
// in client-side rendering.
const filePathContext = path.join(outPath, "index.json");
fs.writeFileSync(filePathContext, JSON.stringify(context));
if (!options.quiet) {
buildCount++;
if (options.verbose) {
console.log("Wrote", filePathContext);
}
}
}
if (!options.quiet) {
console.log(`Built ${buildCount} SPA related files`);
}
}

module.exports = { buildSPAs };

0 comments on commit e58786c

Please sign in to comment.