postcss-remove-declaration

Remove CSS declarations with ease

Usage no npm install needed!

<script type="module">
  import postcssRemoveDeclaration from 'https://cdn.skypack.dev/postcss-remove-declaration';
</script>

README

PostCSS Remove Declaration

PostCSS plugin to remove declarations by selector.

💿 Installation

Via NPM

$ npm install postcss-remove-declaration --save-dev

Via Yarn

$ yarn add postcss-remove-declaration --dev

🚀 Usage

Once you have done the installation, you will need to configure plugin by creating a postcss.config.js file in the root of your project. As an example:

module.exports = {
  plugins: [
    require("postcss-remove-declaration")({
      remove: {
        ".a": "*",
        ".b": "color",
        ".c": ["color", "background-color"],
        ".d": {
          color: "crimson",
          "background-color": "tomato"
        }
      }
    })
  ]
};

⚙️ Properties

Property Required Type Description
remove true String, Array, Object An object where each specified key is a CSS selector and each value is either "*" indicating that all rules for that selector should be removed, a string matching the CSS property name to remove (e.g. color), an array of strings containing CSS properties to be removed (e.g. ["color", "background-color"]), or an object where each entry specifies declaration in which key is a CSS property and value is a CSS value (e.g { color: "cyan" }).

Powered by

  • PostCSS

🔒 License

MIT