-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
🐛 bug report
Setting removeOptionalTags to false in .htmlnanorc has no effect when the builtin HTML minifier is used. This not a big deal of course, but was a bit unexpected and could either be fixed or noted in the docs if it is considered excepted behaviour. Because the minifier does correctly remove the optional tags.
This might confuse others as well see issue #10212 for example, which could be fixed setting removeOptionalTags to false.
🎛 Configuration (.htmlnanorc)
{
"removeOptionalTags": false
}🤔 Expected Behavior
Given this HTML:
<html>
<head><meta charset="utf-8"></head>
<body><script src="main.js" type="module"></script></body>
</html>I would expect something like this html output when setting "removeOptionalTags": false
<html><head><link rel="stylesheet" href="/static/assets.c5adcbde.css"><meta charset="utf-8"></head><body><script src="/static/assets.b6a3fe7b.js" nomodule defer></script><script src="/static/assets.78c31c00.js" type="module"></script> </body></html>😯 Current Behavior
Instead the optional HTML tags <html>, <head> and <body> are striped out. See:
<link rel=stylesheet href=/static/assets.8f303058.css><meta charset=utf-8><script src=/static/assets.b6a3fe7b.js nomodule defer></script><script src=/static/assets.78c31c00.js type=module></script>💁 Possible Solution
Just using htmlnano as optimizer works as expected.
{
"extends": "@parcel/config-default",
"optimizers": {
"*.html": ["@parcel/optimizer-htmlnano"]
}
}🔦 Context
We need even simple HTML-files to have the classic structure <html><head> etc. for legacy parsers in old desktop apps beyond our control to work with our newer frontend.
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | 2.16.1 |
| Node | 24.11.0 |
| npm/Yarn | 24.11.0 |
| Operating System | Ubuntu 24.04.3 LTS |