A webpack plugin that runs Stylelint during the build process to lint CSS, SCSS, SASS, and other style files. Current stable version is 5.1.0, released February 2026. Supports webpack 5 only (for webpack 4, use the 2.x branch). Peer dependencies require Stylelint >=13 up to 17, and Node.js >=18.12.0 (v5 breaking change). Key differentiators: integrates linting directly into webpack compilation, supports caching (enabled by default since v4.1.1), autofixing, and custom formatters. Ships TypeScript types. Alternative to running Stylelint as a separate process or using other linting plugins like eslint-webpack-plugin for styles.
npm install stylelint-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Basic webpack config integrating StylelintPlugin with common options: files glob, caching enabled, and custom config file.
Upgrade Node.js to version 18 or later.
For webpack 4, use 'npm install stylelint-webpack-plugin@2'.
Use 'import StylelintPlugin from 'stylelint-webpack-plugin'' instead of require().
Add 'cache: false' to plugin options or delete cache directory manually when changing Stylelint config.
Upgrade to v5.1.0 if using Stylelint v16 or v17.
Run 'npm install stylelint --save-dev' in your project.
Run 'npm install stylelint-webpack-plugin --save-dev'.
Use 'import StylelintPlugin from 'stylelint-webpack-plugin'' or for CommonJS: 'const StylelintPlugin = require('stylelint-webpack-plugin').default'.