From b503523f66a3310abae5ba892ad66d05ed7a8882 Mon Sep 17 00:00:00 2001 From: Alexander Nestorov Date: Wed, 15 Jun 2022 18:41:03 +0200 Subject: [PATCH] feat(core): allow opting out of HTML minification (#7581) --- packages/docusaurus/src/client/serverEntry.tsx | 4 ++++ website/docs/cli.md | 2 ++ 2 files changed, 6 insertions(+) diff --git a/packages/docusaurus/src/client/serverEntry.tsx b/packages/docusaurus/src/client/serverEntry.tsx index 528a0a96e3a8..f353c05bfdbd 100644 --- a/packages/docusaurus/src/client/serverEntry.tsx +++ b/packages/docusaurus/src/client/serverEntry.tsx @@ -142,6 +142,10 @@ async function doRender(locals: Locals & {path: string}) { }); try { + if (process.env.SKIP_HTML_MINIFICATION === 'true') { + return renderedHtml; + } + // Minify html with https://github.com/DanielRuf/html-minifier-terser return await minify(renderedHtml, { removeComments: false, diff --git a/website/docs/cli.md b/website/docs/cli.md index 5fb2356e777a..2f4f68d85cdf 100644 --- a/website/docs/cli.md +++ b/website/docs/cli.md @@ -94,6 +94,8 @@ Compiles your site for production. For advanced minification of CSS bundle, we use the [advanced cssnano preset](https://github.com/cssnano/cssnano/tree/master/packages/cssnano-preset-advanced) (along with additional several PostCSS plugins) and [level 2 optimization of clean-css](https://github.com/jakubpawlowicz/clean-css#level-2-optimizations). If as a result of this advanced CSS minification you find broken CSS, build your website with the environment variable `USE_SIMPLE_CSS_MINIFIER=true` to minify CSS with the [default cssnano preset](https://github.com/cssnano/cssnano/tree/master/packages/cssnano-preset-default). **Please [fill out an issue](https://github.com/facebook/docusaurus/issues/new?labels=bug%2C+needs+triage&template=bug.md) if you experience CSS minification bugs.** +You can skip the HTML minification with the environment variable `SKIP_HTML_MINIFICATION=true`. + ::: ### `docusaurus swizzle [themeName] [componentName] [siteDir]` {#docusaurus-swizzle}