Skip to content

Commit 2ef40c2

Browse files
authoredJul 15, 2022
chore: Netlify branch deploys should only deploy default locale "en" (#7788)

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed
 

‎website/docusaurus.config.js

+21-12
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ const isDev = process.env.NODE_ENV === 'development';
4646
const isDeployPreview =
4747
!!process.env.NETLIFY && process.env.CONTEXT === 'deploy-preview';
4848

49+
// Netlify branch deploy like "docusaurus-v2"
50+
const isBranchDeploy =
51+
!!process.env.NETLIFY && process.env.CONTEXT === 'branch-deploy';
52+
4953
// Used to debug production build issues faster
5054
const isBuildFast = !!process.env.BUILD_FAST;
5155

@@ -82,15 +86,16 @@ const config = {
8286
],
8387
i18n: {
8488
defaultLocale: 'en',
85-
// eslint-disable-next-line no-nested-ternary
86-
locales: isDeployPreview
87-
? // Deploy preview: keep it fast!
88-
['en']
89-
: isI18nStaging
90-
? // Staging locales: https://docusaurus-i18n-staging.netlify.app/
91-
['en', 'ja']
92-
: // Production locales
93-
['en', 'fr', 'pt-BR', 'ko', 'zh-CN'],
89+
90+
locales:
91+
isDeployPreview || isBranchDeploy
92+
? // Deploy preview and branch deploys: keep them fast!
93+
['en']
94+
: isI18nStaging
95+
? // Staging locales: https://docusaurus-i18n-staging.netlify.app/
96+
['en', 'ja']
97+
: // Production locales
98+
['en', 'fr', 'pt-BR', 'ko', 'zh-CN'],
9499
},
95100
webpack: {
96101
jsLoader: (isServer) => ({
@@ -299,11 +304,15 @@ const config = {
299304
remarkPlugins: [math, [npm2yarn, {sync: true}]],
300305
rehypePlugins: [],
301306
disableVersioning: isVersioningDisabled,
302-
lastVersion: isDev || isDeployPreview ? 'current' : undefined,
307+
lastVersion:
308+
isDev || isDeployPreview || isBranchDeploy ? 'current' : undefined,
303309
onlyIncludeVersions: (() => {
304310
if (isBuildFast) {
305311
return ['current'];
306-
} else if (!isVersioningDisabled && (isDev || isDeployPreview)) {
312+
} else if (
313+
!isVersioningDisabled &&
314+
(isDev || isDeployPreview || isBranchDeploy)
315+
) {
307316
return ['current', ...versions.slice(0, 2)];
308317
}
309318
return undefined;
@@ -341,7 +350,7 @@ const config = {
341350
'./_dogfooding/dogfooding.css',
342351
],
343352
},
344-
gtag: !isDeployPreview
353+
gtag: !(isDeployPreview || isBranchDeploy)
345354
? {
346355
trackingID: 'UA-141789564-1',
347356
}

‎website/netlify.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
command = "yarn --cwd .. build:packages && yarn netlify:build:production"
1818

1919
[context.branch-deploy]
20-
command = "yarn --cwd .. build:packages && yarn netlify:build:production"
20+
command = "yarn --cwd .. build:packages && yarn netlify:build:branchDeploy"
2121

2222
[context.deploy-preview]
2323
command = "yarn --cwd .. build:packages && yarn netlify:build:deployPreview"

‎website/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"build:blogOnly": "cross-env yarn build --config=docusaurus.config-blog-only.js",
2424
"build:fast": "cross-env BUILD_FAST=true yarn build --locale en",
2525
"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",
26-
"netlify:build:deployPreview": "yarn docusaurus write-translations --locale fr --messagePrefix '(fr) ' && yarn build && yarn test:css-order",
26+
"netlify:build:branchDeploy": "yarn build && yarn test:css-order",
27+
"netlify:build:deployPreview": "yarn build && yarn test:css-order",
2728
"netlify:crowdin:delay": "node delayCrowdin.mjs",
2829
"netlify:crowdin:wait": "node waitForCrowdin.mjs",
2930
"netlify:crowdin:downloadTranslations": "yarn netlify:crowdin:wait && yarn --cwd .. crowdin:download:website",

0 commit comments

Comments
 (0)
Please sign in to comment.