From 0e0d1e7bac25e17a4edd59c7d92720768b765bc7 Mon Sep 17 00:00:00 2001 From: Thiago Teixeira Date: Tue, 11 Mar 2025 12:25:29 -0700 Subject: [PATCH 1/3] Set cpu=1 in next.config.js --- next.config.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/next.config.js b/next.config.js index 525b6f3ab..cae0abb34 100644 --- a/next.config.js +++ b/next.config.js @@ -75,6 +75,11 @@ const CSP_HEADER = [ module.exports = { output: "export", + experimental: { + //workerThreads: false, // Not sure if this does anything when cpu=1 + cpus: 1, + }, + webpack: (configuration) => { // Don't try to polyfill the fs module. configuration.resolve.fallback = { fs: false }; From 8980d1d361f22c9d6c5eee6fbfee5764a9702375 Mon Sep 17 00:00:00 2001 From: Thiago Teixeira Date: Tue, 11 Mar 2025 13:07:11 -0700 Subject: [PATCH 2/3] Try to improve build speed a little using worker threads. --- next.config.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/next.config.js b/next.config.js index cae0abb34..f97fcd3c9 100644 --- a/next.config.js +++ b/next.config.js @@ -76,8 +76,9 @@ module.exports = { output: "export", experimental: { - //workerThreads: false, // Not sure if this does anything when cpu=1 - cpus: 1, + workerThreads: true, + cpus: 2, + sharedPool: true, }, webpack: (configuration) => { From d95c4f5630f8f17e933602d8b91710d34a85641d Mon Sep 17 00:00:00 2001 From: Thiago Teixeira Date: Tue, 11 Mar 2025 13:19:28 -0700 Subject: [PATCH 3/3] Make this run on prod only --- next.config.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/next.config.js b/next.config.js index f97fcd3c9..b074155b9 100644 --- a/next.config.js +++ b/next.config.js @@ -1,5 +1,15 @@ const IS_DEV = process.env.NODE_ENV === "development"; +const PROD_OPTIMIZATIONS = IS_DEV + ? {} + : { + experimental: { + workerThreads: true, + cpus: 2, + sharedPool: true, + }, + }; + // IMPORTANT: Keep this in sync with netlify.toml // prettier-ignore const CSP_HEADER = [ @@ -75,11 +85,7 @@ const CSP_HEADER = [ module.exports = { output: "export", - experimental: { - workerThreads: true, - cpus: 2, - sharedPool: true, - }, + ...PROD_OPTIMIZATIONS, webpack: (configuration) => { // Don't try to polyfill the fs module.