From 2ef40c2598de25c056a8cbaad2671b82e260d513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Fri, 15 Jul 2022 12:45:08 +0200 Subject: [PATCH] chore: Netlify branch deploys should only deploy default locale "en" (#7788) --- website/docusaurus.config.js | 33 +++++++++++++++++++++------------ website/netlify.toml | 2 +- website/package.json | 3 ++- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index b4bc19997ae2..5f9f7da058e6 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -46,6 +46,10 @@ const isDev = process.env.NODE_ENV === 'development'; const isDeployPreview = !!process.env.NETLIFY && process.env.CONTEXT === 'deploy-preview'; +// Netlify branch deploy like "docusaurus-v2" +const isBranchDeploy = + !!process.env.NETLIFY && process.env.CONTEXT === 'branch-deploy'; + // Used to debug production build issues faster const isBuildFast = !!process.env.BUILD_FAST; @@ -82,15 +86,16 @@ const config = { ], i18n: { defaultLocale: 'en', - // eslint-disable-next-line no-nested-ternary - locales: isDeployPreview - ? // Deploy preview: keep it fast! - ['en'] - : isI18nStaging - ? // Staging locales: https://docusaurus-i18n-staging.netlify.app/ - ['en', 'ja'] - : // Production locales - ['en', 'fr', 'pt-BR', 'ko', 'zh-CN'], + + locales: + isDeployPreview || isBranchDeploy + ? // Deploy preview and branch deploys: keep them fast! + ['en'] + : isI18nStaging + ? // Staging locales: https://docusaurus-i18n-staging.netlify.app/ + ['en', 'ja'] + : // Production locales + ['en', 'fr', 'pt-BR', 'ko', 'zh-CN'], }, webpack: { jsLoader: (isServer) => ({ @@ -299,11 +304,15 @@ const config = { remarkPlugins: [math, [npm2yarn, {sync: true}]], rehypePlugins: [], disableVersioning: isVersioningDisabled, - lastVersion: isDev || isDeployPreview ? 'current' : undefined, + lastVersion: + isDev || isDeployPreview || isBranchDeploy ? 'current' : undefined, onlyIncludeVersions: (() => { if (isBuildFast) { return ['current']; - } else if (!isVersioningDisabled && (isDev || isDeployPreview)) { + } else if ( + !isVersioningDisabled && + (isDev || isDeployPreview || isBranchDeploy) + ) { return ['current', ...versions.slice(0, 2)]; } return undefined; @@ -341,7 +350,7 @@ const config = { './_dogfooding/dogfooding.css', ], }, - gtag: !isDeployPreview + gtag: !(isDeployPreview || isBranchDeploy) ? { trackingID: 'UA-141789564-1', } diff --git a/website/netlify.toml b/website/netlify.toml index 18eae1b40844..1ff3f6d3c3a7 100644 --- a/website/netlify.toml +++ b/website/netlify.toml @@ -17,7 +17,7 @@ command = "yarn --cwd .. build:packages && yarn netlify:build:production" [context.branch-deploy] - command = "yarn --cwd .. build:packages && yarn netlify:build:production" + command = "yarn --cwd .. build:packages && yarn netlify:build:branchDeploy" [context.deploy-preview] command = "yarn --cwd .. build:packages && yarn netlify:build:deployPreview" diff --git a/website/package.json b/website/package.json index ff9aab04830d..e684aad13551 100644 --- a/website/package.json +++ b/website/package.json @@ -23,7 +23,8 @@ "build:blogOnly": "cross-env yarn build --config=docusaurus.config-blog-only.js", "build:fast": "cross-env BUILD_FAST=true yarn build --locale en", "netlify:build:production": "yarn docusaurus write-translations && yarn netlify:crowdin:delay && yarn netlify:crowdin:uploadSources && yarn netlify:crowdin:downloadTranslations && yarn build && yarn test:css-order", - "netlify:build:deployPreview": "yarn docusaurus write-translations --locale fr --messagePrefix '(fr) ' && yarn build && yarn test:css-order", + "netlify:build:branchDeploy": "yarn build && yarn test:css-order", + "netlify:build:deployPreview": "yarn build && yarn test:css-order", "netlify:crowdin:delay": "node delayCrowdin.mjs", "netlify:crowdin:wait": "node waitForCrowdin.mjs", "netlify:crowdin:downloadTranslations": "yarn netlify:crowdin:wait && yarn --cwd .. crowdin:download:website",