A webpack loader that generates responsive images with multiple sizes and formats (including WebP and AVIF) from a single source, outputting a srcset attribute. The current stable version is 3.1.2, requiring webpack 5 and Node >=12.22.1. It offers two adapters: sharp (recommended for performance and format support) and jimp (pure JavaScript, slower but no native deps). Key differentiators include TypeScript support, flexibility with query parameters (sizes, format, quality), and easy integration with modern responsive image patterns. Release cadence is irregular, with major breaking changes in v3.0.0 moving to webpack 5 and TypeScript refactor.
npm install responsive-loaderVerified import paths — ran on the pinned version, not inferred.
Configures responsive-loader with sharp adapter to generate resized images (300,600,1024,2048) and placeholder, then imports an image with inline query parameters.
Upgrade to webpack 5 and responsive-loader >=3.0.0
If using CommonJS, update require path; e.g., require('responsive-loader/sharp') still works but internal structure changed.If relying on jimp, explicitly set adapter: require('responsive-loader/jimp') in options.Add type: 'javascript/auto' in the loader rule (see webpack config).
Always include at least sizes[] parameter in the import path, e.g., 'image.jpg?sizes[]=600'.
Add rule for /.(png|jpe?g)$/ with responsive-loader and set type: 'javascript/auto'.
Run 'npm install sharp' or switch to jimp adapter by setting adapter: require('responsive-loader/jimp').Use --ignore-engines flag or switch to jimp: adapter: require('responsive-loader/jimp').