mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-08 13:52:36 +02:00
perf(website): optimize website i18n build time by removing useless git log calls (#11214)
This commit is contained in:
parent
2b15b85645
commit
ad56077c70
2 changed files with 26 additions and 15 deletions
|
@ -12,6 +12,12 @@ import type {Options as DocsOptions} from '@docusaurus/plugin-content-docs';
|
||||||
import type {Options as BlogOptions} from '@docusaurus/plugin-content-blog';
|
import type {Options as BlogOptions} from '@docusaurus/plugin-content-blog';
|
||||||
import type {Options as PageOptions} from '@docusaurus/plugin-content-pages';
|
import type {Options as PageOptions} from '@docusaurus/plugin-content-pages';
|
||||||
|
|
||||||
|
// By default, we don't want to run "git log" commands on i18n sites
|
||||||
|
// This makes localized sites build much slower on Netlify
|
||||||
|
// See also https://github.com/facebook/docusaurus/issues/11208
|
||||||
|
// TODO duplicated :/
|
||||||
|
export const showLastUpdate = process.env.DOCUSAURUS_CURRENT_LOCALE === 'en';
|
||||||
|
|
||||||
export const isArgosBuild = process.env.DOCUSAURUS_ARGOS_BUILD === 'true';
|
export const isArgosBuild = process.env.DOCUSAURUS_ARGOS_BUILD === 'true';
|
||||||
|
|
||||||
if (isArgosBuild) {
|
if (isArgosBuild) {
|
||||||
|
@ -62,8 +68,8 @@ export const dogfoodingPluginInstances: PluginConfig[] = [
|
||||||
|
|
||||||
// Using a _ prefix to test against an edge case regarding MDX partials: https://github.com/facebook/docusaurus/discussions/5181#discussioncomment-1018079
|
// Using a _ prefix to test against an edge case regarding MDX partials: https://github.com/facebook/docusaurus/discussions/5181#discussioncomment-1018079
|
||||||
path: '_dogfooding/_docs tests',
|
path: '_dogfooding/_docs tests',
|
||||||
showLastUpdateTime: true,
|
showLastUpdateTime: showLastUpdate,
|
||||||
showLastUpdateAuthor: true,
|
showLastUpdateAuthor: showLastUpdate,
|
||||||
sidebarItemsGenerator(args) {
|
sidebarItemsGenerator(args) {
|
||||||
return args.defaultSidebarItemsGenerator({
|
return args.defaultSidebarItemsGenerator({
|
||||||
...args,
|
...args,
|
||||||
|
@ -122,8 +128,8 @@ export const dogfoodingPluginInstances: PluginConfig[] = [
|
||||||
id: 'pages-tests',
|
id: 'pages-tests',
|
||||||
path: '_dogfooding/_pages tests',
|
path: '_dogfooding/_pages tests',
|
||||||
routeBasePath: '/tests/pages',
|
routeBasePath: '/tests/pages',
|
||||||
showLastUpdateTime: true,
|
showLastUpdateTime: showLastUpdate,
|
||||||
showLastUpdateAuthor: true,
|
showLastUpdateAuthor: showLastUpdate,
|
||||||
editUrl: ({pagesPath}) =>
|
editUrl: ({pagesPath}) =>
|
||||||
`https://github.com/facebook/docusaurus/edit/main/website/_dogfooding/_pages tests/${pagesPath}`,
|
`https://github.com/facebook/docusaurus/edit/main/website/_dogfooding/_pages tests/${pagesPath}`,
|
||||||
} satisfies PageOptions,
|
} satisfies PageOptions,
|
||||||
|
|
|
@ -157,6 +157,11 @@ function getLocalizedConfigValue(key: keyof typeof ConfigLocalized) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// By default, we don't want to run "git log" commands on i18n sites
|
||||||
|
// This makes localized sites build much slower on Netlify
|
||||||
|
// See also https://github.com/facebook/docusaurus/issues/11208
|
||||||
|
const showLastUpdate = process.env.DOCUSAURUS_CURRENT_LOCALE === defaultLocale;
|
||||||
|
|
||||||
export default async function createConfigAsync() {
|
export default async function createConfigAsync() {
|
||||||
return {
|
return {
|
||||||
title: 'Docusaurus',
|
title: 'Docusaurus',
|
||||||
|
@ -318,8 +323,8 @@ export default async function createConfigAsync() {
|
||||||
blogTitle: 'Docusaurus changelog',
|
blogTitle: 'Docusaurus changelog',
|
||||||
// Not useful, but permits to run git commands earlier
|
// Not useful, but permits to run git commands earlier
|
||||||
// Otherwise the sitemap plugin will run them in postBuild()
|
// Otherwise the sitemap plugin will run them in postBuild()
|
||||||
showLastUpdateAuthor: true,
|
showLastUpdateAuthor: showLastUpdate,
|
||||||
showLastUpdateTime: true,
|
showLastUpdateTime: showLastUpdate,
|
||||||
blogDescription:
|
blogDescription:
|
||||||
'Keep yourself up-to-date about new features in every release',
|
'Keep yourself up-to-date about new features in every release',
|
||||||
blogSidebarCount: 'ALL',
|
blogSidebarCount: 'ALL',
|
||||||
|
@ -355,8 +360,8 @@ export default async function createConfigAsync() {
|
||||||
remarkPlugins: [npm2yarn],
|
remarkPlugins: [npm2yarn],
|
||||||
editCurrentVersion: true,
|
editCurrentVersion: true,
|
||||||
sidebarPath: './sidebarsCommunity.js',
|
sidebarPath: './sidebarsCommunity.js',
|
||||||
showLastUpdateAuthor: true,
|
showLastUpdateAuthor: showLastUpdate,
|
||||||
showLastUpdateTime: true,
|
showLastUpdateTime: showLastUpdate,
|
||||||
} satisfies DocsOptions,
|
} satisfies DocsOptions,
|
||||||
],
|
],
|
||||||
!process.env.DOCUSAURUS_SKIP_BUNDLING && [
|
!process.env.DOCUSAURUS_SKIP_BUNDLING && [
|
||||||
|
@ -490,8 +495,8 @@ export default async function createConfigAsync() {
|
||||||
admonitions: {
|
admonitions: {
|
||||||
keywords: ['my-custom-admonition'],
|
keywords: ['my-custom-admonition'],
|
||||||
},
|
},
|
||||||
showLastUpdateAuthor: true,
|
showLastUpdateAuthor: showLastUpdate,
|
||||||
showLastUpdateTime: true,
|
showLastUpdateTime: showLastUpdate,
|
||||||
remarkPlugins: [[npm2yarn, {sync: true}], remarkMath, configTabs],
|
remarkPlugins: [[npm2yarn, {sync: true}], remarkMath, configTabs],
|
||||||
rehypePlugins: [rehypeKatex],
|
rehypePlugins: [rehypeKatex],
|
||||||
disableVersioning: isVersioningDisabled,
|
disableVersioning: isVersioningDisabled,
|
||||||
|
@ -524,8 +529,8 @@ export default async function createConfigAsync() {
|
||||||
blog: {
|
blog: {
|
||||||
// routeBasePath: '/',
|
// routeBasePath: '/',
|
||||||
path: 'blog',
|
path: 'blog',
|
||||||
showLastUpdateAuthor: true,
|
showLastUpdateAuthor: showLastUpdate,
|
||||||
showLastUpdateTime: true,
|
showLastUpdateTime: showLastUpdate,
|
||||||
editUrl: ({locale, blogDirPath, blogPath}) => {
|
editUrl: ({locale, blogDirPath, blogPath}) => {
|
||||||
if (locale !== defaultLocale) {
|
if (locale !== defaultLocale) {
|
||||||
return `https://crowdin.com/project/docusaurus-v2/${locale}`;
|
return `https://crowdin.com/project/docusaurus-v2/${locale}`;
|
||||||
|
@ -562,8 +567,8 @@ export default async function createConfigAsync() {
|
||||||
}
|
}
|
||||||
return `https://github.com/facebook/docusaurus/edit/main/website/src/pages/${pagesPath}`;
|
return `https://github.com/facebook/docusaurus/edit/main/website/src/pages/${pagesPath}`;
|
||||||
},
|
},
|
||||||
showLastUpdateAuthor: true,
|
showLastUpdateAuthor: showLastUpdate,
|
||||||
showLastUpdateTime: true,
|
showLastUpdateTime: showLastUpdate,
|
||||||
} satisfies PageOptions,
|
} satisfies PageOptions,
|
||||||
theme: {
|
theme: {
|
||||||
customCss: [
|
customCss: [
|
||||||
|
@ -582,7 +587,7 @@ export default async function createConfigAsync() {
|
||||||
? undefined
|
? undefined
|
||||||
: // Note: /tests/docs already has noIndex: true
|
: // Note: /tests/docs already has noIndex: true
|
||||||
['/tests/{blog,pages}/**'],
|
['/tests/{blog,pages}/**'],
|
||||||
lastmod: 'date',
|
lastmod: showLastUpdate ? 'date' : null,
|
||||||
priority: null,
|
priority: null,
|
||||||
changefreq: null,
|
changefreq: null,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue