Skip to content

Commit

Permalink
change html minifier params to avoid hydration errors
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Dec 20, 2024
1 parent b5359db commit 984f00e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/docusaurus-bundler/src/minifyHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ async function getTerserMinifier(): Promise<HtmlMinifier> {
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,
Expand Down Expand Up @@ -84,8 +88,13 @@ async function getSwcMinifier(): Promise<HtmlMinifier> {
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 <a target="_self">
removeRedundantAttributes: 'smart',

minifyJs: true,
minifyJson: true,
minifyCss: true,
Expand Down

0 comments on commit 984f00e

Please sign in to comment.