Subscribe on changes!

Make it possible to retain html comments

avatar
Nov 13th 2020

Please note, that this request is concerning vue sfc files. (.vue-files)

What problem does this feature solve?

For technologies like server-side-includes it is really important to retain html comments in certain scenarios. There was an option to retain them for vue-2 (https://vuejs.org/v2/api/#comments), however, that seems to be removed from vue-3 :( I could not find anything concerning this feature in the vue-3 docs.

What does the proposed API look like?

an option would be to keep the v-2 api

avatar
Nov 13th 2020
avatar
Nov 13th 2020

Hi, thanks for your swift response. I am not sure if I understand the context of your linked PR & issue, but to me it sounds like only useful in a situation where I am using the parse() function of vue/compiler-core. In my scenario, I am creating a new instance of a vue component inside of a sfc file. In vue2, the comments: <boolean> option was exposed directly in the options of a component, however that api has now changed (because if configured there, the comments are still lost), and I do not understand where I would specify that option now.

avatar
Nov 13th 2020

try <template comments>, this is the syntax for vue 2, haven't really tried this with vue 3

avatar
Nov 13th 2020

hi vhoyer, I have just tried that and sadly, it did not preserve my comments. ty for the input though

avatar
Jan 24th 2021

From what I gather, the <template comments> capability is not supported in Vue 3 SFCs? Is there any workaround available? In my case, the HTML comments are being stripped out only in production mode, and I'm confused where the root cause of the behaviour lies; my webpack config, the internal behaviour of @vue/compiler-sfc, or just Vue 3 in general?

avatar
Feb 19th 2021

@ferencbeutel4711 Could you find a solution?

avatar
Mar 27th 2021

@JasperTey your case looks behaving this way because of this internal compiler bug: https://github.com/vuejs/vue-next/issues/3392