In my project I am using a lot of JavaScript template string. After webpack compilation that is resulting in newlines, tabs and white spaces. How can I remove it with regex or any DOM API like document.createTreeWalker? I hope there would be easy regex to replace these.
Here is my source
const employees = ['Rajkeshwar', 'Suresh', 'Manoj', 'Ramesh', 'Sudhir'];
const domStr = `
<h1>Employee List</h1>
<ul class="employee-list">
${employees.reduce((str, emp) => {
str += `<li>${emp}</li>`;
return str;
}, '')}
</ul>
`;
This is what I get after compilation
var employees = ["Rajkeshwar", "Suresh", "Manoj", "Ramesh", "Sudhir"];
var domStr = '\n <h1>Employee List</h1>\n <ul class="employee-list">\n '.concat(
employees.reduce(function(str, emp) {
str += "<li>".concat(emp, "</li>");
return str;
}, ""),
"\n </ul>\n"
);