parcel build ./index.html --out-dir dist/static --public-url /static
HTML comments should stay inside the outputed index.html file.
All comments are removed from this file.
Not so much a solution but a workaround. Could use plain strings instead of comments.
I'm trying to server-side render a ReactJS application which I would replace HTML comment with the server-generated HTML. I realise I could use a string like 'replace-me' but it seems a hack around and may get messy down the road.
<!DOCTYPE html>
<html>
<head>
<title>My react app</title>
<script defer src='./src/client/index.tsx'></script>
<style>body { margin: 0 }</style>
<!-- HEAD -->
</head>
<body>
<div id="app"><!-- BODY --></div>
</body>
</html>
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.12.3
| Node | 10.16.3
| npm/Yarn | 1.17.3 (Yarn)
| Operating System | MacOS Mojave (10.14.6)
Have you tried adding a .htmlnanorc config with
{
"removeComments": false
}
?
I have, no luck. Do I need to point to this config anywhere?
Just put the config file next to your package.json
Works for me: https://github.com/mischnic/parcel-issue-3535-htmlnano-comment
with this output:
<!DOCTYPE html><html><head><title>My react app</title><style>body{margin:0}</style><!-- HEAD --></head><body> <div id="app"><!-- BODY --></div> </body></html>
My apologies, this was a caching issue. Deleting my cache and trying this worked great.
I'll reopen my issue on docs as I haven't seen this on the website
Most helpful comment
My apologies, this was a caching issue. Deleting my cache and trying this worked great.
I'll reopen my issue on docs as I haven't seen this on the website