Registry / devops / swig-minifier

swig-minifier

JSON →
library0.4.4-bjsnpmunverified

Middleware for Express that automatically minifies and caches HTML output rendered by the Swig template engine. Version 0.4.4-b is the latest and only release, last updated in 2016. Supports file, memory, or Redis caching with configurable hash algorithms (md5, sha512, sha256). No longer maintained; Swig itself is deprecated in favor of Nunjucks. Works only with Node >=0.10 and Swig. Key differentiator: seamless integration with Express app.engine.

npm install swig-minifier
INSTALL
IMPORT
SIG · SWIG-MINIFIER
S
swig-minifier
devopsjavascriptv0.4.4-b
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.

swigMinifier
const swigMinifier = require('swig-minifier');
import swigMinifier from 'swig-minifier';
Package uses CommonJS and does not provide ESM exports. Use require only.

Demonstrates basic setup of swig-minifier with Express, including init and engine replacement.

const express = require('express'); const swigMinifier = require('swig-minifier'); const app = express(); // Initialize with custom options (optional) swigMinifier.init({ cacheType: 'memory', hashGen: 'md5' }); // Set swig-minifier as the engine for .html files app.engine('html', swigMinifier.engine); // Render a template using res.render app.get('/', function(req, res) { res.render('index.html', { title: 'Hello' }); }); app.listen(3000);
Debug
Known issues
gotchaSwig template engine is deprecated; this package is unmaintained since 2016. Use with Nunjucks or other modern engines is not supported.
fix
Migrate to a maintained HTML minification approach (e.g., html-minifier + custom caching).
affects: >=0.0.0
breaking.clearCache() on Redis issues a flushAll command, which clears ALL keys in the Redis database, not just swig-minifier's keys.
fix
Avoid using Redis cacheType or manually implement targeted cache clearing.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'swig'
swig-minifier requires swig as a peer dependency, but it is not installed.
fix
Run: npm install swig
Upgrade
Version history
0.4.4-blatest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
swig-minifier — npm install swig-minifier · libregistry