Registry / devops / lit-html-minifier-loader

lit-html-minifier-loader

JSON →
library1.0.0jsnpmunverified

A webpack loader that minifies HTML templates inside JavaScript/TypeScript template string literals used by lit-html and similar libraries. Version 1.0.0 is the initial stable release. It is designed to be chained after a TypeScript or JavaScript loader to reduce the size of tagged template literals containing HTML. The loader processes .ts or .js files, minifying the HTML content within template literals using HTML minification techniques. It supports optional debug mode and integrates seamlessly into webpack builds. Compared to alternatives like babel-plugin-template-html-minifier, this works as a webpack loader and is easier to set up in webpack projects.

npm install lit-html-minifier-loader
INSTALL
IMPORT
SIG · LIT-HTML-MINIFIER-
L
lit-html-minifier-loader
devopsjavascriptv1.0.0
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.

default (no named export)
module.exports = { loader: 'lit-html-minifier-loader' }
import litHtmlMinifier from 'lit-html-minifier-loader'
This package exports a webpack loader function via CommonJS, not an ESM module. Use require or config object.
Options
// In webpack config: { loader: 'lit-html-minifier-loader', options: { debug: true } }
new LitHtmlMinifierLoader()
Options are passed via the webpack loader options object, not as a constructor.

Configures webpack to run lit-html-minifier-loader after ts-loader on .element.ts files, minifying HTML in template literals.

// webpack.config.js const path = require('path'); module.exports = { module: { rules: [ { test: /\.element\.ts$/, use: [ { loader: 'ts-loader' }, { loader: 'lit-html-minifier-loader', options: { debug: false, }, }, ], include: [path.join(__dirname, 'src')], }, ], }, };
Debug
Known issues
gotchaLoader must run after TypeScript compilation to minify processed template literals.
fix
Ensure lit-html-minifier-loader comes after ts-loader in the 'use' array.
affects: >=1.0.0
gotchaLoader only processes files whose module name contains '.element' by default (via test regex).
fix
Adjust the test pattern to match your desired files: /\.ts$/ or other regex.
affects: >=1.0.0
missingNo options documentation provided; only 'debug' is known.
fix
Check source code or use package with minimal configuration.
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'lit-html-minifier-loader'
Package not installed or not in devDependencies.
fix
Run 'npm install -D lit-html-minifier-loader'
Error: Cannot find module 'html-minifier'
Missing peer dependency for html-minifier.
fix
Run 'npm install html-minifier' alongside the loader.
TypeError: loaderContext.getResolve is not a function
Using an outdated version of webpack (<5). This loader expects webpack 5 API.
fix
Upgrade webpack to version 5 or later.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
lit-html-minifier-loader — npm install lit-html-minifier-loader · libregistry