HTML comments being removed on build
See original GitHub issue🐛 bug report
🎛 Configuration (.babelrc, package.json, cli command)
parcel build ./index.html --out-dir dist/static --public-url /static
🤔 Expected Behavior
HTML comments should stay inside the outputed index.html
file.
😯 Current Behavior
All comments are removed from this file.
💁 Possible Solution
Not so much a solution but a workaround. Could use plain strings instead of comments.
🔦 Context
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.
💻 Code Sample
<!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>
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | 1.12.3 |
Node | 10.16.3 |
npm/Yarn | 1.17.3 (Yarn) |
Operating System | MacOS Mojave (10.14.6) |
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Webpack remove HTML comments on production build
to remove comments in html in production mode, you need the plugin, HtmlWebpackPlugin, in the Minification option put removeComments: true, ...
Read more >Hiding/Unhiding Items With HTML Comments
Commenting out items is useful when you don't want to completely delete something. Using HTML comments will let you add or remove...
Read more >How to Comment & Comment Out in HTML - HubSpot Blog
Comments can help you explain, organize, and debug your code. Learn how to add them in your HTML so you code faster and...
Read more >How to Remove HTML Comments from the Page Source
There's more than one way to remove these comments, and, in some cases, the best solution is to stop them being created in...
Read more >gatsby-remark-remove-comments
By default, in Remark, HTML comments in Markdown will appear in the output, this plugin removes them. For the following Markdown file: #...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
Works for me: https://github.com/mischnic/parcel-issue-3535-htmlnano-comment with this output: