Skip to content

Commit

Permalink
feat: Added separate minimal build setting (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel S authored Aug 27, 2022
1 parent 6394e50 commit 4958f5d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -50,6 +51,7 @@ module.exports = {
SERVER_API_KEY,
REVALIDATE_TOKEN,
ANALYZE,
MINIMAL_BUILD,
BASE_PATH,
CLIENT_API_URL,
VIDEO_URL,
Expand Down
9 changes: 5 additions & 4 deletions src/utils/fetchStaticPaths.ts
Original file line number Diff line number Diff line change
@@ -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<T extends ParsedUrlQuery = ParsedUrlQuery>(
fetchPaths: () => Promise<Array<{ params: T }>>,
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"
Expand Down

0 comments on commit 4958f5d

Please sign in to comment.