https://codesandbox.io/s/tender-hooks-b90d5?file=/pages/index.vue
Add an HTML comment in a component.
<template>
<div>Test comments
<!--comment here-->
</div>
</template>
<div id="__layout">
<div class="container">
<div>Test comments
<!--comment here-->
</div>
</div>
</div>
<div id="__layout">
<div class="container">
<div>Test comments
</div>
</div>
</div>
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.
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.
Most helpful comment
Ok after searching a lot I found the key. The only necessary thing is to add
commentsattribute to<template>tag. It isn't documented invue-loader.https://github.com/vuejs/vue-loader/pull/897