diff --git a/packages/docusaurus-bundler/src/minifyHtml.ts b/packages/docusaurus-bundler/src/minifyHtml.ts index 4a029d83c1f6..28f7292b53d0 100644 --- a/packages/docusaurus-bundler/src/minifyHtml.ts +++ b/packages/docusaurus-bundler/src/minifyHtml.ts @@ -47,9 +47,13 @@ async function getTerserMinifier(): Promise { minify: async function minifyHtmlWithTerser(html) { try { const code = await terserHtmlMinifier(html, { + // When enabled => React hydration errors removeComments: false, - removeRedundantAttributes: true, - removeEmptyAttributes: true, + removeRedundantAttributes: false, + removeEmptyAttributes: false, + sortAttributes: false, + sortClassName: false, + removeScriptTypeAttributes: true, removeStyleLinkTypeAttributes: true, useShortDoctype: true, @@ -84,8 +88,13 @@ async function getSwcMinifier(): Promise { sortSpaceSeparatedAttributeValues: false, sortAttributes: false, - removeRedundantAttributes: 'all', - removeEmptyAttributes: true, + // When enabled => hydration error for className={"yt-lite "} + normalizeAttributes: false, + // When enabled => hydration error for className="" + removeEmptyAttributes: false, + // When enabled => hydration error for + removeRedundantAttributes: 'smart', + minifyJs: true, minifyJson: true, minifyCss: true,