From 984f00e7c64522528f8916c49332979d6a3844d8 Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 20 Dec 2024 23:13:29 +0100 Subject: [PATCH] change html minifier params to avoid hydration errors --- packages/docusaurus-bundler/src/minifyHtml.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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,