sasslint-webpack-plugin
raw JSON → 1.0.4 verified Sat Apr 25 auth: no javascript deprecated
Webpack plugin for running sass-lint on SCSS/SASS files during build. Version 1.0.4 is the latest and last release; the package depends on sass-lint ^1.8.0, which is itself deprecated in favor of stylelint. The plugin lints files based on a glob pattern and reports errors/warnings via webpack. Unlike loaders, this plugin works with non-JS files and supports integration with extract-text-webpack-plugin. It offers options for config file, context, ignore patterns, and fail-on-warning/error. No longer actively maintained; users should migrate to sass-lint alternatives.
Common errors
error Error: Cannot find module 'sass-lint' ↓
cause sass-lint is a peer dependency and is not installed automatically.
fix
Run 'npm install sass-lint@^1.8.0' to install the peer dependency.
error sassLintPlugin is not a constructor ↓
cause Using import statement or calling the function without 'new'.
fix
Use 'const sassLintPlugin = require('sasslint-webpack-plugin');' and instantiate with 'new sassLintPlugin(options)'.
error WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. ↓
cause Using the plugin with webpack 5, which changed plugin API requirements.
fix
Upgrade to a webpack 5 compatible lint plugin (e.g., stylelint-webpack-plugin).
Warnings
deprecated sass-lint is deprecated in favor of stylelint. This plugin relies on sass-lint and will not receive updates. ↓
fix Migrate to stylelint with webpack stylelint-webpack-plugin.
breaking Requires Node.js 4+ and webpack 1.x/2.x; incompatible with webpack 5 and Node.js >=17. ↓
fix Use a modern linting plugin compatible with your webpack and Node versions.
gotcha Using with extract-text-webpack-plugin causes duplicate lint output unless you add it to ignorePlugins. ↓
fix Add 'extract-text-webpack-plugin' to ignorePlugins array in options.
gotcha NoErrorsPlugin in webpack config will fail the build on any lint warning, regardless of failOnWarning setting. ↓
fix Remove NoErrorsPlugin from webpack configuration or set failOnWarning to false.
Install
npm install sasslint-webpack-plugin yarn add sasslint-webpack-plugin pnpm add sasslint-webpack-plugin Imports
- default wrong
import sassLintPlugin from 'sasslint-webpack-plugin';correctconst sassLintPlugin = require('sasslint-webpack-plugin'); - new sassLintPlugin wrong
plugins: [sassLintPlugin({ /* options */ })]correctplugins: [new sassLintPlugin({ /* options */ })] - options.glob wrong
glob: '**/*.scss'correctglob: '**/*.s?(a|c)ss'
Quickstart
const sassLintPlugin = require('sasslint-webpack-plugin');
module.exports = {
// ... other webpack config
plugins: [
new sassLintPlugin({
configFile: '.sass-lint.yml',
context: ['src/styles'],
ignoreFiles: ['src/styles/vendor/**'],
glob: '**/*.s?(a|c)ss',
quiet: false,
failOnWarning: false,
failOnError: true
})
]
};