feat(core): allow opting out of HTML minification (#7581)

This commit is contained in:
Alexander Nestorov 2022-06-15 18:41:03 +02:00 committed by GitHub
parent 1f0440074a
commit b503523f66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View file

@ -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,

View file

@ -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}