Merge branch 'docusaurus-v2' into slorber/port-v2-netlify-changes

This commit is contained in:
sebastienlorber 2022-07-15 13:05:51 +02:00
commit a80f5a7b05
3 changed files with 26 additions and 13 deletions

View file

@ -46,6 +46,10 @@ const isDev = process.env.NODE_ENV === 'development';
const isDeployPreview = const isDeployPreview =
!!process.env.NETLIFY && process.env.CONTEXT === 'deploy-preview'; !!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 // Used to debug production build issues faster
const isBuildFast = !!process.env.BUILD_FAST; const isBuildFast = !!process.env.BUILD_FAST;
@ -82,15 +86,16 @@ const config = {
], ],
i18n: { i18n: {
defaultLocale: 'en', defaultLocale: 'en',
// eslint-disable-next-line no-nested-ternary
locales: isDeployPreview locales:
? // Deploy preview: keep it fast! isDeployPreview || isBranchDeploy
['en'] ? // Deploy preview and branch deploys: keep them fast!
: isI18nStaging ['en']
? // Staging locales: https://docusaurus-i18n-staging.netlify.app/ : isI18nStaging
['en', 'ja'] ? // Staging locales: https://docusaurus-i18n-staging.netlify.app/
: // Production locales ['en', 'ja']
['en', 'fr', 'pt-BR', 'ko', 'zh-CN'], : // Production locales
['en', 'fr', 'pt-BR', 'ko', 'zh-CN'],
}, },
webpack: { webpack: {
jsLoader: (isServer) => ({ jsLoader: (isServer) => ({
@ -299,11 +304,15 @@ const config = {
remarkPlugins: [math, [npm2yarn, {sync: true}]], remarkPlugins: [math, [npm2yarn, {sync: true}]],
rehypePlugins: [], rehypePlugins: [],
disableVersioning: isVersioningDisabled, disableVersioning: isVersioningDisabled,
lastVersion: isDev || isDeployPreview ? 'current' : undefined, lastVersion:
isDev || isDeployPreview || isBranchDeploy ? 'current' : undefined,
onlyIncludeVersions: (() => { onlyIncludeVersions: (() => {
if (isBuildFast) { if (isBuildFast) {
return ['current']; return ['current'];
} else if (!isVersioningDisabled && (isDev || isDeployPreview)) { } else if (
!isVersioningDisabled &&
(isDev || isDeployPreview || isBranchDeploy)
) {
return ['current', ...versions.slice(0, 2)]; return ['current', ...versions.slice(0, 2)];
} }
return undefined; return undefined;
@ -341,7 +350,7 @@ const config = {
'./_dogfooding/dogfooding.css', './_dogfooding/dogfooding.css',
], ],
}, },
gtag: !isDeployPreview gtag: !(isDeployPreview || isBranchDeploy)
? { ? {
trackingID: 'UA-141789564-1', trackingID: 'UA-141789564-1',
} }

View file

@ -16,6 +16,9 @@
[context.production] [context.production]
command = "yarn --cwd .. build:packages && yarn netlify:build:production" command = "yarn --cwd .. build:packages && yarn netlify:build:production"
[context.branch-deploy]
command = "yarn --cwd .. build:packages && yarn netlify:build:branchDeploy"
[context.deploy-preview] [context.deploy-preview]
command = "yarn --cwd .. build:packages && yarn netlify:build:deployPreview" command = "yarn --cwd .. build:packages && yarn netlify:build:deployPreview"

View file

@ -23,7 +23,8 @@
"build:blogOnly": "cross-env yarn build --config=docusaurus.config-blog-only.js", "build:blogOnly": "cross-env yarn build --config=docusaurus.config-blog-only.js",
"build:fast": "cross-env BUILD_FAST=true yarn build --locale en", "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: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:delay": "node delayCrowdin.mjs",
"netlify:crowdin:wait": "node waitForCrowdin.mjs", "netlify:crowdin:wait": "node waitForCrowdin.mjs",
"netlify:crowdin:downloadTranslations": "yarn netlify:crowdin:wait && yarn --cwd .. crowdin:download:website", "netlify:crowdin:downloadTranslations": "yarn netlify:crowdin:wait && yarn --cwd .. crowdin:download:website",