V
V
Valery Chupurnov2019-11-07 12:39:25
Template Engines
Valery Chupurnov, 2019-11-07 12:39:25

How to remove extra indentation in a JavaScript template?

I think that the problem is not so common due to the fact that most users use React + JSX, Vue and Angular. But often in VanilaJS I write code like this

function getTemplate() {
     const html = `<div>
           <span>Привет</span>
     </div>`;
    return html;
}

I am using webpack. After compressing such code, extra spaces, hyphens and tabs still remain in the html line.
Because of this, the bundle swells a lot. I do not want to throw such small lines into a separate file.
write like this
function getTemplate() {
     const html = `<div>
<span>Привет</span>
</div>`;
    return html;
}

I also don't really want to.
Is there any plugin or setting that would compress such strings?

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