B
B
BonBon Slick2020-05-13 18:43:23
JavaScript
BonBon Slick, 2020-05-13 18:43:23

Output the same piece of code for all templates?

I noticed this, I have a lot of index.vue and all the code is completely identical

<template src="./_template.html"/>
<script lang="ts"
        src="./_index.ts"
/>
<style lang='scss'
       module
       src="./_styles.scss"
       type='text/scss'
/>
<docs>
    Short usage description
</docs>


I would like to declare it in one file and output it in all others with some kind of macro, webpack plugin at build time. There are times when you need to change the name or path of a file and have to manually update it.

An example of the output of a common piece of code for all templates
@import('index_vue_template')

Do I think the same way in Angular / React?

Something tells me that there may be an answer here, because. there are no .vue templates, only .ts/.html, but how to do it for .scss too?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question