Nuxt.js: HTML comments are removed

Created on 8 May 2020  路  1Comment  路  Source: nuxt/nuxt.js

Version

v2.12.2

Reproduction link

https://codesandbox.io/s/tender-hooks-b90d5?file=/pages/index.vue

Steps to reproduce

Add an HTML comment in a component.

<template>
  <div>Test comments
    <!--comment here-->
  </div>
</template>

What is expected ?

<div id="__layout">
    <div class="container">
        <div>Test comments
        <!--comment here-->
        </div>
    </div>
</div>

What is actually happening?

<div id="__layout">
    <div class="container">
        <div>Test comments
        </div>
    </div>
</div>

Additional comments?

I have tried fix it adding comment: true to layout and page and adding some build configuration:

    html: {
      minify: {
        removeComments: false
      }
    },

    terser: {
      extractComments: false
    },

But It doesn't work.

This bug report is available on Nuxt community (#c10630)
bug-report

Most helpful comment

Ok after searching a lot I found the key. The only necessary thing is to add comments attribute to <template> tag. It isn't documented in vue-loader.

https://github.com/vuejs/vue-loader/pull/897

>All comments

Ok after searching a lot I found the key. The only necessary thing is to add comments attribute to <template> tag. It isn't documented in vue-loader.

https://github.com/vuejs/vue-loader/pull/897

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VincentLoy picture VincentLoy  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments

msudgh picture msudgh  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments

gary149 picture gary149  路  3Comments