Registry / devops / squeezit

squeezit

JSON →
library1.17.0jsnpmunverified

Squeezit (current stable version 1.17.0) is a versatile, lossless-first image optimization utility offered as a command-line interface (CLI), a JavaScript/TypeScript API, and a comprehensive suite of bundler plugins. It targets a wide array of modern and legacy image formats including PNG, JPEG, GIF, WebP, SVG, AVIF, HEIC, JXL, ICO, and BMP, focusing on reducing file sizes without noticeable degradation. The project exhibits active development, frequently integrating with contemporary build tools. Its key differentiators include broad format support, a user-friendly CLI with clear output, robust pattern matching for file selection (supporting shell-style and glob expressions), and a safe, threshold-based replacement mechanism to prevent unnecessary file churn. Squeezit integrates directly with ecosystems like Gulp, Grunt, Vite, Webpack, Rollup, Parcel, Astro, Next.js, esbuild, and Babel, making it suitable for a diverse range of development workflows and CI/CD pipelines.

npm install squeezit
INSTALL
IMPORT
SIG · SQUEEZIT
S
squeezit
devopsjavascriptv1.17.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

optimizeFile
import { optimizeFile } from 'squeezit'
const { optimizeFile } = require('squeezit')
The primary API functions are ESM-first. While CJS might work via transpilation, direct require is not the idiomatic usage.
squeezitGulp
import { squeezitGulp } from 'squeezit/gulp'
import squeezitGulp from 'squeezit/gulp'
Gulp plugin is a named export from its specific subpath.
registerSqueezitTask
const { registerSqueezitTask } = require('squeezit/grunt')
import { registerSqueezitTask } from 'squeezit/grunt'
The Grunt plugin is designed for CommonJS `require` due to typical Gruntfile environments.
squeezitVite
import { squeezitVite } from 'squeezit/vite'
const { squeezitVite } = require('squeezit/vite')
Vite plugin is a named ESM export.

Demonstrates programmatic image optimization using the core `optimizeFile` API, creating a temporary file and reporting optimization results.

import { optimizeFile } from 'squeezit'; import { promises as fs } from 'fs'; import path from 'path'; async function runOptimization() { const imagePath = path.join(process.cwd(), 'example.png'); const outputPath = path.join(process.cwd(), 'optimized-example.png'); // Create a dummy image file for demonstration if it doesn't exist try { await fs.access(imagePath); } catch (error) { console.log(`Creating dummy file at ${imagePath}`); // Minimal PNG base64 representation (1x1 transparent PNG) const dummyPngBuffer = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=', 'base64'); await fs.writeFile(imagePath, dummyPngBuffer); } console.log(`Optimizing ${imagePath}...`); const result = await optimizeFile(imagePath, { output: outputPath, overwrite: true, // Overwrite if target path is the same dryRun: false // Set to true to preview without saving }); if (result.success) { console.log(`Optimization successful:`); console.log(` Original size: ${result.originalSize} bytes`); console.log(` Optimized size: ${result.optimizedSize} bytes`); console.log(` Reduction: ${((1 - result.optimizedSize / result.originalSize) * 100).toFixed(2)}%`); console.log(` Output to: ${outputPath}`); } else { console.error(`Optimization failed: ${result.error}`); } // Clean up the dummy file await fs.unlink(imagePath); if (result.success) { await fs.unlink(outputPath); } } runOptimization().catch(console.error);
squeezit --version
Debug
Known issues
gotchaWhen using Squeezit's bundler plugins (e.g., for Webpack, Vite, Gulp), their respective peer dependencies (e.g., 'webpack', 'vite', 'gulp') must be installed separately in your project. Failure to do so, or using incompatible versions, will result in runtime errors. Squeezit will not install these automatically.
fix
Manually install the required peer dependencies using your package manager (e.g., `npm install webpack` or `yarn add gulp`) ensuring version compatibility as specified in Squeezit's `peerDependencies`.
affects: >=1.0.0
gotchaThe `squeezit` CLI is often installed globally (`npm install -g squeezit`). While convenient, ensure the global version aligns with any local project dependencies or specific plugin requirements to avoid unexpected behavior or command failures due to version mismatches.
fix
Prefer local installation (`npm install squeezit`) and run via `npx squeezit` in projects to ensure correct versioning, or use a version manager like `fnm` or `nvm` for global installations.
affects: >=1.0.0
gotchaSqueezit emphasizes a 'lossless-first' approach. While it provides aggressive compression, users expecting significant file size reductions that typically come with lossy compression might find the results less dramatic than anticipated. For maximum reduction, additional lossy steps might be required.
fix
Review the optimization goals. If aggressive lossy compression is needed, integrate a separate lossy optimization step or tool into your workflow before or after Squeezit, or explore Squeezit's options for near-lossless modes if available.
affects: >=1.0.0
gotchaWhen using glob expressions (e.g., `images/**/*.jpg`) with the CLI, recursive scanning is not enabled by default. You must explicitly include the `-r` or `--recursive` flag for Squeezit to process files in subdirectories.
fix
Always use `squeezit -r "your/glob/**/*.pattern"` when you intend to optimize images within nested folders.
affects: >=1.0.0
Errors
Common errors & fixes
command not found: squeezit
The `squeezit` CLI tool is not installed globally or is not in your system's PATH.
fix
Install globally with `npm install -g squeezit` or `bun add -g squeezit`. Alternatively, if installed locally, run with `npx squeezit`.
Error: Cannot find module 'webpack' from 'squeezit/webpack'
A Squeezit bundler plugin (e.g., Webpack, Vite, Gulp) was used without its corresponding peer dependency installed in the project.
fix
Install the missing peer dependency: `npm install webpack` (or `vite`, `gulp`, etc., depending on the plugin in use).
Error: Image processing failed for file 'path/to/image.png': [detailed error message]
An unexpected issue occurred during the image optimization process, potentially due to a corrupted file, unsupported image format variant, or an internal library error.
fix
Check the detailed error message for clues. Verify the image file's integrity and ensure it's a supported format. Consider reporting the issue to the Squeezit project with the full error and file details.
Upgrade
Version history
1.17.0latest on npm
Audit
Dependencies
@babel/coreoptionalPeer dependency for the Babel plugin integration. Must be installed separately if using the plugin.
esbuildoptionalPeer dependency for the esbuild plugin integration. Must be installed separately if using the plugin.
gulpoptionalPeer dependency for the Gulp plugin integration. Must be installed separately if using the plugin.
gruntoptionalPeer dependency for the Grunt plugin integration. Must be installed separately if using the plugin.
nextoptionalPeer dependency for the Next.js wrapper integration. Must be installed separately if using the wrapper.
astrooptionalPeer dependency for the Astro wrapper integration. Must be installed separately if using the wrapper.
parceloptionalEngine and peer dependency for the Parcel optimizer plugin integration. Must be installed separately if using the plugin.
rollupoptionalPeer dependency for the Rollup plugin integration. Must be installed separately if using the plugin.
typescriptoptionalPeer dependency, especially relevant for TypeScript projects using the API or plugins. Must be installed separately.
viteoptionalPeer dependency for the Vite plugin integration. Must be installed separately if using the plugin.
webpackoptionalPeer dependency for the Webpack plugin integration. Must be installed separately if using the plugin.
Agent activity
5 hits · last 30 days
node
4
Resources
squeezit — npm install squeezit · libregistry