javascript - A way to minify or uglify ES6 Template Strings -
something like
var tpl = ` <div> template <span>string</span> </div> `
will produce:
var tpl = "\n<div> \n template\n <span>string</span>\n</div>\n";
what need rid of spaces , maybe line breaks, other html minification tools do.
so should become similar to:
"<div>template<span>string</span></div>"
are there ways achieve wisely , indestructible?
the best approach using tagged template, like
var tpl = minifyhtml ` <div> template <span>string</span> </div> `;
you can start with
function minifyhtml(parts, ...values) { var out = []; out.push(parts[0]); (var = 1; i<parts.length; i++) out.push(parts[i], string(arguments[i])); return out.join(""); }
which same no tag.
now can extend minify parts
of template dynamically, tpl
become expected string.
the next step introduce static optimisation in compile pipeline. figure out how write rule matches tagged template expressions in ast tag identifier minifyhtml
, , evaluate minification part of compiling/bundling es6/typescript source distributed files.
Comments
Post a Comment