Search code examples
javascriptparceljs

How to stop ParcelJS removing HTML comments on build


When building my application all HTML comments are removed.

I've tried searching the docs and couldn't find anywhere stating that comments are removed at build.

For example this comment would be removed:

<!-- BODY -->

Some context

I'm trying to server-side render a ReactJS application which I would replace this comment with. I realise I could do a string replacement with something like 'replace-me' but it seems a hack around for something that I should be able to turn off.

The question

How would I keep HTML comments after building my application?


Solution

  • To solve this issue

    Create a .htmlnanorc with the following:

    {
      "removeComments": false
    }
    

    (clear the cached files as well)