Skip to content

PostCSS plugin to limit used declarations to a given set

License

Notifications You must be signed in to change notification settings

songsterr/postcss-sayonara

Repository files navigation

PostCSS Sayonara

PostCSS plugin to limit used declarations to a given set.

version node-current npm licence Snyk Vulnerabilities for npm package

.foo {
  /* Input example */
  fill: #fff;
  cursor: pointer;
}
.foo {
  /* Output example */
  fill: #fff;
}

Usage

Check you project for existed PostCSS config: postcss.config.js in the project root, "postcss" section in package.json or postcss in bundle config.

If you already use PostCSS, add the plugin to plugins list:

module.exports = {
  plugins: [
+   require('postcss-sayonara')({
+     allowedPropNames: [
+       'stroke', 'stroke-width', 'stroke-opacity', 'stroke-dasharray',
+       'stroke-dashoffset', 'stroke-linecap',
+       'stroke-linejoin', 'stroke-miterlimit',
+       'fill', 'fill-rule', 'fill-opacity',
+       'clip-path', 'mask',
+       'opacity', 'color', 'stop-color', 'stop-opacity',
+       'font-family', 'font-size', 'font-weight',
+       'text-anchor', 'visibility', 'display',
+     ],
+   }),
    require('autoprefixer'),
  ],
}

If you do not use PostCSS, add it according to official docs and set this plugin in settings.