Parcel: How disable htmlnano on production?

Created on 21 Jan 2019  ·  8Comments  ·  Source: parcel-bundler/parcel

❔ How disable htmlnano on production?

In production build I'm not need to minify html.

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.11.0
| Node | 11.7.0
| Yarn | 1.7.0
| Operating System | macOS Mojave

Question

Most helpful comment

this as a .htmlnanorc might do less minification:

{
    "collapseAttributeWhitespace": false,
    "collapseBooleanAttributes": false,
    "collapseWhitespace": "conservative",
    "custom": [],
    "deduplicateAttributeValues": false,
    "mergeScripts": false,
    "mergeStyles": false,
    "removeUnusedCss": false,
    "minifyJson": false,
    "minifySvg": false,
    "removeEmptyAttributes": false,
    "removeRedundantAttributes": false,
    "removeComments": false
}

All 8 comments

By using --no-minify

Yes it's work. But styles and scripts do not minify too. In my situation I expect not minify only html.

this as a .htmlnanorc might do less minification:

{
    "collapseAttributeWhitespace": false,
    "collapseBooleanAttributes": false,
    "collapseWhitespace": "conservative",
    "custom": [],
    "deduplicateAttributeValues": false,
    "mergeScripts": false,
    "mergeStyles": false,
    "removeUnusedCss": false,
    "minifyJson": false,
    "minifySvg": false,
    "removeEmptyAttributes": false,
    "removeRedundantAttributes": false,
    "removeComments": false
}

this as a .htmlnanorc might do less minification:

{
    "collapseAttributeWhitespace": false,
    "collapseBooleanAttributes": false,
    "collapseWhitespace": "conservative",
    "custom": [],
    "deduplicateAttributeValues": false,
    "mergeScripts": false,
    "mergeStyles": false,
    "removeUnusedCss": false,
    "minifyJson": false,
    "minifySvg": false,
    "removeEmptyAttributes": false,
    "removeRedundantAttributes": false,
    "removeComments": false
}

Yes it's work! But prop collapseWhitespace is must has false value too. Thanks!

Yes it's work! But prop collapseWhitespace is must has false value too. Thanks!

That's true.

@vUdav I suggest you to use the --no-minify flag and then minify css/js with third party tools. I use postcss with cssnano during the build and i run a postbuild script to optimize only js

this as a .htmlnanorc might do less minification:

{
    "collapseAttributeWhitespace": false,
    "collapseBooleanAttributes": false,
    "collapseWhitespace": "conservative",
    "custom": [],
    "deduplicateAttributeValues": false,
    "mergeScripts": false,
    "mergeStyles": false,
    "removeUnusedCss": false,
    "minifyJson": false,
    "minifySvg": false,
    "removeEmptyAttributes": false,
    "removeRedundantAttributes": false,
    "removeComments": false
}

Thank you.

It helps a lot because htmlnano removes all display: none tags, and this is where I save my SVG before using it like:

<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
      <symbol id="kud-Svg--github" viewBox="0 0 512 512">
        <title>github</title>
        <path
          d="M461.633 250.645l.367-3.82c-22.896-2.22-45.667-2.418-67.79-.73 3.557-11.346 5.43-24.163 5.295-38.738-.292-30.965-10.616-55.08-26.843-75.096 3.116-18.85.77-37.7-5.11-56.56-23.188 1.898-44.054 9.493-62.635 22.686-34.725-7.044-69.447-7.493-104.172 0-21.673-14.627-42.956-21.802-63.91-22.686-6.21 20.765-7.168 41.233-1.916 61.357-18.28 19.397-25.27 42.944-24.926 69.02.196 14.926 2.496 28.208 6.738 39.95-21.796-1.598-44.2-1.385-66.732.8l.367 3.818c22.947-2.228 45.76-2.41 67.92-.678.813 1.974 1.632 3.94 2.566 5.815-24.01-.633-45.618 1.453-65.854 6.43l.913 3.723c20.538-5.048 42.54-7.08 67.107-6.254 16.246 28.865 47.52 45.825 93.063 51.206-10.58 8.594-16.27 18.73-17.735 30.2h-24.12c-32.395 0-41.227-41.303-74.78-37.228C132 320 125.5 371.598 177.588 371.598h21.88v47.297c.234 7.643-3.093 12.754-8.47 16.297 18.655 1.884 32.675-7.43 32.675-18.854V353.82l5.833-6v72.992c.245 7.265-3.284 11.392-7.03 15.34 16.433.653 31.89-2.63 32.59-16.616V349.68s5.757-3.6 5.757 0v66.58c.17 11.8 10.36 21.366 31.953 19.892-5.776-4.65-7.55-9.35-7.55-16.15v-72.18s5.95-.307 5.95 6v60.88c0 13.55 16.268 19.14 34.83 18.615-6.08-4.558-10.196-9.99-10.223-17.256v-73.216c-.63-10.762-5.003-20.906-13.582-30.358 41.63-6.392 71.638-23.01 86.58-52.796 24.646-.847 46.714 1.183 67.306 6.246l.914-3.723c-20.394-5.014-42.18-7.096-66.416-6.415.84-1.89 1.67-3.79 2.39-5.785 22.39-1.798 45.457-1.622 68.66.632zM114 310.023c-1.023 0-1.853-.588-1.853-1.313 0-.728.83-1.315 1.853-1.315 1.024 0 1.854.588 1.854 1.315 0 .726-.83 1.313-1.854 1.313zm5.833 3.98c-1.137 0-2.06-.653-2.06-1.46s.923-1.462 2.06-1.462 2.06.656 2.06 1.463-.923 1.46-2.06 1.46zm5.917 5.17c-1.333 0-2.415-.767-2.415-1.713s1.082-1.714 2.415-1.714 2.416.768 2.416 1.714-1.083 1.712-2.416 1.712zm5.75 6.206c-1.56 0-2.825-.897-2.825-2.004s1.265-2.005 2.825-2.005 2.825.9 2.825 2.006-1.265 2.003-2.825 2.003zm6.333 7.014c-1.733 0-3.14-.996-3.14-2.226s1.407-2.228 3.14-2.228 3.14.998 3.14 2.228-1.407 2.226-3.14 2.226zm7.334 7.123c-1.926 0-3.488-1.107-3.488-2.474s1.56-2.476 3.487-2.476c1.925 0 3.487 1.11 3.487 2.476s-1.562 2.474-3.487 2.474zm9.916 6.774c-2.14 0-3.875-1.23-3.875-2.748 0-1.52 1.735-2.75 3.875-2.75s3.875 1.23 3.875 2.75c0 1.518-1.735 2.75-3.875 2.75zm12.292 3.626c-2.14 0-3.875-1.23-3.875-2.75 0-1.518 1.735-2.75 3.875-2.75s3.875 1.232 3.875 2.75c0 1.52-1.735 2.75-3.875 2.75zm12.958.417c-2.14 0-3.875-1.23-3.875-2.75 0-1.518 1.735-2.75 3.875-2.75s3.875 1.232 3.875 2.75c0 1.52-1.735 2.75-3.875 2.75zm12.792.25c-2.14 0-3.875-1.23-3.875-2.75 0-1.518 1.735-2.75 3.875-2.75s3.875 1.232 3.875 2.75c0 1.52-1.735 2.75-3.875 2.75z"
        />
      </symbol>
    </svg>

                <svg role="img" class="kud-Svg kud-Svg--github">
                  <use href="#kud-Svg--github"></use>
                </svg>

So I had no SVG anymore.

The answer is here: minifySvg: false,

Are there any other .htmlnanorc to turn off even less minification? I really wish there is a simple option to simply turn off htmlnano and keep css/js minification on.

For my copy & pasta friends, here is the right config, taking note of the previous comments.

.htmlnanorc

{
  "collapseAttributeWhitespace": false,
  "collapseBooleanAttributes": false,
  "collapseWhitespace": false,
  "custom": [],
  "deduplicateAttributeValues": false,
  "mergeScripts": false,
  "mergeStyles": false,
  "removeUnusedCss": false,
  "minifyJson": false,
  "minifySvg": false,
  "removeEmptyAttributes": false,
  "removeRedundantAttributes": false,
  "removeComments": false
}
Was this page helpful?
0 / 5 - 0 ratings