client/build: fix minifying adding ghost spaces
HTML minifier added ghost spaces around some of <%- %> even despite <!-- --> trick.
This commit is contained in:
parent
6e3462187d
commit
e291369701
|
@ -99,7 +99,20 @@ function bundleHtml(config) {
|
|||
compiledTemplateJs += 'let templates = {};';
|
||||
for (const file of files) {
|
||||
const name = path.basename(file, '.tpl').replace(/_/g, '-');
|
||||
const templateText = minifyHtml(readTextFile(file, 'utf-8'));
|
||||
const placeholders = [];
|
||||
let templateText = readTextFile(file, 'utf-8');
|
||||
templateText = templateText.replace(
|
||||
/<%.*?%>/ig,
|
||||
(match) => {
|
||||
const ret = '%%%TEMPLATE' + placeholders.length;
|
||||
placeholders.push(match);
|
||||
return ret;
|
||||
});
|
||||
templateText = minifyHtml(templateText);
|
||||
templateText = templateText.replace(
|
||||
/%%%TEMPLATE(\d+)/g,
|
||||
(match, number) => { return placeholders[number]; });
|
||||
|
||||
const functionText = underscore.template(
|
||||
templateText, {variable: 'ctx'}).source;
|
||||
compiledTemplateJs += `templates['${name}'] = ${functionText};`;
|
||||
|
|
Loading…
Reference in New Issue