Skip to content

Commit

Permalink
feat(core): allow opting out of HTML minification (#7581)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandernst committed Jun 15, 2022
1 parent 1f04400 commit b503523
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/docusaurus/src/client/serverEntry.tsx
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions website/docs/cli.md
Expand Up @@ -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}
Expand Down

0 comments on commit b503523

Please sign in to comment.