Registry / devops / minify-template-literal-loader

minify-template-literal-loader

JSON →
library0.0.3jsnpmunverified

A webpack loader (v0.0.3) that minifies JavaScript files containing template literals using html-minifier. It processes template literal strings in .js files, reducing whitespace and applying HTML minification. Requires html-minifier as a peer dependency. Useful for projects embedding HTML templates directly in JavaScript to avoid separate HTML file imports. Minimal version, infrequent updates. Differentiator: focuses solely on template literals, not whole HTML files.

npm install minify-template-literal-loader
INSTALL
IMPORT
SIG · MINIFY-TEMPLATE-LI
M
minify-template-literal-loader
devopsjavascriptv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

webpack rule configuration
{ test: /\.template\.js$/, loader: 'minify-template-literal-loader', options: { collapseWhitespace: true } }
Using loader after babel instead of before
Place loader before transpilers like babel; webpack runs loaders right-to-left, bottom-to-top.
require('html-minifier').minify
const { minify } = require('html-minifier');
Internal usage; not typically imported by user.
package.json dependency
"minify-template-literal-loader": "^0.0.3"
Omitting html-minifier from peerDependencies
Installing without html-minifier causes runtime error.

Configures webpack to minify template literals in .template.js files before further processing.

// webpack.config.js module.exports = { module: { rules: [ { test: /\.template\.js$/, use: { loader: 'minify-template-literal-loader', options: { collapseWhitespace: true, conservativeCollapse: false, removeComments: true } } }, { test: /\.js$/, exclude: /\.template\.js$/, use: 'babel-loader' } ] } };
Debug
Known issues
gotchaLoader must be applied before transpilers like babel due to webpack's right-to-left loader execution order.
fix
Ensure minify-template-literal-loader appears after babel-loader in the rules array (since webpack processes bottom-to-top).
affects: *
deprecatedhtml-minifier is unmaintained and may have security issues; consider using html-minifier-terser instead.
fix
Replace peer dependency html-minifier with html-minifier-terser and update options accordingly.
affects: >=0.0.3
gotchaThe loader only minifies template literals that are exported or assigned to variables; inline expressions like `${}` may not be fully optimized.
fix
Manually review template literals with complex interpolations; consider using a babel plugin for more comprehensive minification.
affects: *
breakingNo breaking changes reported due to minimal versions and low usage.
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'html-minifier'
Missing required peer dependency html-minifier.
fix
npm install html-minifier --save-dev
Error: html-minifier is not a function
Incorrect peer dependency version or html-minifier not installed.
fix
Ensure html-minifier is properly installed: npm install html-minifier@3.5.7 --save-dev
Module parse failed: Unexpected token (1:0)
Loader not applied; template literals are not being processed before transpilation.
fix
Add loader rule for .template.js files and ensure it is placed before babel-loader in the config.
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies
html-minifierrequiredpeer dependency for HTML minification
Agent activity
2 hits · last 30 days
node
2
Resources
minify-template-literal-loader — npm install minify-template-literal-loader · libregistry