Mollify is a Node.js middleware that integrates the `minify` package, providing on-the-fly minification of static assets like JavaScript, CSS, and HTML files. It is primarily designed for use with web frameworks such as Express, streamlining the process of serving optimized content. The current stable version is 6.0.0, released after several iterative updates that include dropping support for older Node.js versions (now requiring Node.js >=16) and a significant transition to ESM in version 5.0.0. The package has a moderate release cadence, often driven by updates to its core `minify` dependency or environmental changes. Its key differentiator lies in its straightforward integration as an Express middleware, offering a simple solution for asset optimization without requiring complex build pipelines, making it suitable for rapid development and certain production environments.
npm install mollifyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates setting up an Express server that uses mollify middleware to serve minified static content from the current directory.
Upgrade Node.js to version 16 or higher, or pin 'mollify' to a version compatible with your current Node.js (e.g., `<6.0.0` for Node.js <16).
Migrate your project to ESM if not already, or use dynamic `import()` if you need to load mollify from a CommonJS context (though this is not recommended). Update all `require('mollify')` to `import mollify from 'mollify'`.Upgrade Node.js to version 14 or higher.
Upgrade Node.js to version 12 or higher.
For mollify v5.0.0+, ensure you are using `import mollify from 'mollify';`. If in an older CommonJS context, ensure `require('mollify')` is used correctly as a function.Use the provided ESM boilerplate to define `__filename` and `__dirname` from `import.meta.url`: `import {fileURLToPath} from 'url'; import {dirname} from 'path'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename);`Verify that the `dir` option in `mollify({ dir: ... })` accurately reflects the root directory where `express.static` is serving files from. Ensure `is: true` or omit the `is` property as `true` is the default.