Giter VIP home page Giter VIP logo

css-byebye's Introduction

CSS Byebye

CSS Byebye is a node module that lets you explicitly remove the CSS rules that you don't want.

Description

It's very simple: pass him a list of selectors that you want to exclude and it will remove them and the associated rules from your CSS.

I've found some cases where this approach is easier than using more powerful tools like uncss. Use what's best for you and give some feedback :)

CSS Byebye is built with postcss postcss.

Note: A grunt task for CSS Byebye is currently being developed.

API

CSS Byebye is a CSS post processor built with postcss; part of its API is defined as in the postcss docs.

It exposes a process method with the following signature:

process(css, options)
  • css is your stylesheet
  • options is an object that has at least the rulesToRemove property defined.

rulesToRemove is an array of strings or regular expressions (selectors).

If you provide a string, it will remove the rule(s) for this exact selector.

Examples

var cssbyebye = require('css-byebye')

var css = 'a { font-size: 12px; } .hello .h1 { background: red } .world { color: blue }'
var rulesToRemove = ['.hello .h1', '.world']

var result = cssbyebye.process(css, { rulesToRemove: rulesToRemove, map: false })

result will be an object like this:

{
  css: 'a { font-size: 12px; }'
}

If you use the postcss map option, then it will be added to the result object.

You can mix strings and regular expressions

var rulesToRemove = ['.hello', /.*\.world.*/]

In this case, it would remove a rule with the exact selector .hello and any rule that contains the .world class.

Changelog

2015-10-19 v0.2.0

  • The default behaviour is to match the exact selector when a string is given.
  • Added the possibility to match with regular expressions.

css-byebye's People

Contributors

aodev avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.