From 4958f5d462d88ec59994d9a598e3b408701d5ab8 Mon Sep 17 00:00:00 2001 From: Manuel S Date: Sat, 27 Aug 2022 20:06:36 +0200 Subject: [PATCH] feat: Added separate minimal build setting (#144) --- src/utils/config.js | 2 ++ src/utils/fetchStaticPaths.ts | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/utils/config.js b/src/utils/config.js index a78928b6c5e..38d7ed4edfb 100644 --- a/src/utils/config.js +++ b/src/utils/config.js @@ -12,6 +12,7 @@ const SERVER_API_KEY = process.env.ANIMETHEMES_API_KEY; const REVALIDATE_TOKEN = process.env.REVALIDATE_TOKEN; const ANALYZE = !!process.env.ANALYZE; +const MINIMAL_BUILD = !!process.env.MINIMAL_BUILD; // Server-side + Client-side @@ -50,6 +51,7 @@ module.exports = { SERVER_API_KEY, REVALIDATE_TOKEN, ANALYZE, + MINIMAL_BUILD, BASE_PATH, CLIENT_API_URL, VIDEO_URL, diff --git a/src/utils/fetchStaticPaths.ts b/src/utils/fetchStaticPaths.ts index d99c6e168bc..2321faf4871 100644 --- a/src/utils/fetchStaticPaths.ts +++ b/src/utils/fetchStaticPaths.ts @@ -1,12 +1,13 @@ -import { STAGING } from "utils/config"; +import { MINIMAL_BUILD } from "utils/config"; import type { ParsedUrlQuery } from "querystring"; export default async function fetchStaticPaths( fetchPaths: () => Promise>, - allPathsInStaging = false + forceFullBuild = false ): Promise<{ paths: Array<{ params: T }>, fallback: "blocking" }> { - // In development and staging all pages should be fetched on-demand. This speeds up page generation a lot. - if (process.env.NODE_ENV === "development" || (STAGING && !allPathsInStaging)) { + // In development all pages should be fetched on-demand. This speeds up page generation a lot. + // This can also be enabled via an enviroment variable. + if (process.env.NODE_ENV === "development" || (MINIMAL_BUILD && !forceFullBuild)) { return { paths: [], fallback: "blocking"