Registry / devops / lint-staged-imagemin

lint-staged-imagemin

JSON →
library1.3.0jsnpmunverified

Easily configure imagemin to work with lint-staged. This npm package (v1.3.0, latest) provides a simple wrapper to run imagemin optimization on staged files within the lint-staged pipeline. It is designed for developers using lint-staged who want to automatically compress images (PNG, JPEG, GIF, SVG) as part of their pre-commit hooks. The package is lightweight but depends on imagemin and its plugins being installed separately. It is a niche utility with low release cadence (last update ~5 years ago). Alternative: use imagemin directly in a lint-staged config.

npm install lint-staged-imagemin
INSTALL
IMPORT
SIG · LINT-STAGED-IMAGEM
L
lint-staged-imagemin
devopsjavascriptv1.3.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.

lintStagedImagemin
import lintStagedImagemin from 'lint-staged-imagemin'
const lintStagedImagemin = require('lint-staged-imagemin').default
ESM-only; default export is a function that returns a configuration object for lint-staged.
imageminPngquant
import imageminPngquant from 'imagemin-pngquant'
const imageminPngquant = require('imagemin-pngquant')
CommonJS require works but ESM is recommended; plugin must be installed separately.
lintStagedImagemin Type
import type { Options } from 'lint-staged-imagemin'
import { Options } from 'lint-staged-imagemin'
Type import for TypeScript; Options is not a runtime value.

Shows how to use lint-staged-imagemin in a lint-staged configuration file to optimize images before commit.

// lint-staged.config.js import lintStagedImagemin from 'lint-staged-imagemin'; export default { '*.{png,jpg,jpeg,gif,svg}': [ lintStagedImagemin({ plugins: [ 'imagemin-pngquant', 'imagemin-mozjpeg' ], options: { 'imagemin-pngquant': { quality: [0.6, 0.8] } } }) ] };
Debug
Known issues
breakingThe package is ESM-only since v1.0.0. Using require() will throw an error.
fix
Use import instead of require; if using CommonJS, install @esm2 cjs wrapper or use dynamic import.
affects: >=1.0.0
deprecatedPackage has not been updated in over 5 years. imagemin core and plugins may have breaking changes.
fix
Consider using imagemin directly in lint-staged config or switch to sharp-based tools.
affects: *
gotchaRequires imagemin and its plugins to be installed separately. Common mistake: forgetting to install imagemin-plugins.
fix
Install imagemin and desired plugins as devDependencies.
affects: *
gotchaThe function returns a string, not an array. lint-staged expects array of commands, but this package returns a single lint-staged command string.
fix
Do not wrap with array brackets; the returned string is the command itself.
affects: *
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module from not supported
Using require() with an ESM-only package.
fix
Change to import statement or use dynamic import().
Error: Cannot find module 'imagemin-pngquant'
Required imagemin plugin not installed.
fix
Run: npm install --save-dev imagemin-pngquant
TypeError: lintStagedImagemin is not a function
Incorrect import of default export, possibly using named import instead of default.
fix
Use: import lintStagedImagemin from 'lint-staged-imagemin'
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
lint-staged-imagemin — npm install lint-staged-imagemin · libregistry