'How do I make webpack display a Vue.js component with a script element?

I wrote a Vue.js component that transforms some data and outputs them as schema.org JSON-LD:

<template>
   <script type="application/ld+json">
       {{json}}
   </script>
</template>

All works well on the dev server but when I build for production the <script> element is gone. I made it work by wrapping a <div hidden> around the <script> but I consider this a dirty hack.

Probably some webpack optimization is responsible for this but I just don't know where to look for it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source