Webpack plugin that converts a set of images into a spritesheet and generates SASS/LESS/Stylus mixins using spritesmith and spritesheet-templates. Current stable version is 1.1.0 (2018). Low release cadence; last commit in 2018. Key differentiator: integrates sprite generation into webpack build pipeline, eliminating the need for separate gulp/grunt tasks. Alternatives: webpack-spritesmith is the only dedicated webpack sprite plugin; gulp.spritesmith is a gulp equivalent. Supports watch mode via gaze. Requires separate file-loader for the generated sprite image. Works with webpack 4 and earlier; likely incompatible with webpack 5 without modifications.
npm install webpack-spritesmithVerified import paths — ran on the pinned version, not inferred.
Configures webpack-spritesmith to generate a sprite sheet from PNG icons and produce Stylus mixins, with file-loader for the image and resolve alias for generated files.
Consider forking or using an alternative; test with webpack 5 before using in production.
Use asset modules (type: 'asset/resource') instead of file-loader in webpack 5 configs.
Add a rule for PNG images using file-loader or asset module, and ensure resolve.modules includes the output directory.
Set cssImageRef to '~sprite.png' (or the relative path from CSS to image) and ensure the image is in a resolved module path.
Ensure the sprite plugin runs only once; consider using webpack.optimize.LimitChunkCountPlugin or similar.
npm install spritesmith --save-dev
Migrate to webpack 4 or use a maintained fork like 'webpack-spritesmith2'.
Use const SpritesmithPlugin = require('webpack-spritesmith'); instead of import.Ensure target.image path is correct and file-loader or asset module handles the PNG file. Add the output directory to resolve.modules.