Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (html-template-cleaner) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
html-template-cleaner
This utility removes extraneous whitespace from template literals containing formatted HTML.
For example, the following method renders an address and the code is formatted for readability.
function renderAddress(addr) {
return `
<div>
<div>${addr.line1}</div>
<div>${addr.city}, ${addr.state} ${addr.postalCode}</div>
</div>
`;
}After bundling and minifying the code, the whitespace between the HTML tags will still be present.
The html-template-cleaner reduces the above to the following:
function renderAddress(addr) {
return `<div><div>${addr.line1}</div><div>${addr.city}, ${addr.state} ${addr.postalCode}</div></div>`;
}Install
npm install html-template-cleanerUsage
html-template-cleaner <directory>
All *.js files in the directory will be processed by the cleaner. The names of the files will remain the same.
Here is an example of using this with esbuild.
"scripts": {
"build": "esbuild index.js login.js --bundle --minify --format=esm --outdir=./dist & html-template-cleaner ./dist"
}Whitespace Removal
The following whitespace is removed:
- whitespace between
>and< - whitespace between
>and${ - whitespace between
}and<