Giter VIP home page Giter VIP logo

stylehacks's Introduction

stylehacks Build Status NPM version Dependency Status

Detect/remove browser hacks from CSS files.

Install

With npm do:

npm install stylehacks --save

Example

In its default mode, stylehacks will remove hacks from your CSS file, based on the browsers that you wish to support.

Input

h1 {
    _color: white;
    color: rgba(255, 255, 255, 0.5);
}

Output

h1 {
    color: rgba(255, 255, 255, 0.5);
}

API

stylehacks.detect(node)

Type: function
Returns: boolean

This method will take any PostCSS node, run applicable plugins depending on its type, then will return a boolean depending on whether it found any of the supported hacks. For example, if the decl node found below is passed to the detect function, it will return true. But if the rule node is passed, it will return false instead.

h1 { _color: red }

stylehacks.process(css, [options]).then(function(result) {})

options

browsers

Type: string|array
Default: browserslist defaults

Specify the browsers that you wish to support. The string will be passed directly to browserslist and parsed, however if an array is passed instead then stylehacks will use it instead of parsing the browsers itself.

lint

Type: boolean
Default: false

If lint mode is enabled, stylehacks will not remove hacks from the CSS; instead, it will warn that hacks were found. When using stylehacks as a PostCSS plugin, you are expected to handle these messages yourself.

silent

Type: boolean
Default: false

Used in combination with the lint option; disables all logging. When using the CLI, the process will exit with 0 or 1 as usual.

sourcemap

Type: boolean
Default: false

Generate a sourcemap with the transformed CSS.

postcss([ stylehacks(opts) ])

stylehacks can also be consumed as a PostCSS plugin. See the documentation for examples for your environment.

CLI

stylehacks also ships with a CLI app. To see the available options, just run:

$ stylehacks --help

Related

stylehacks works well with your existing PostCSS setup:

  • stylelint - Comprehensive & modern CSS linter, to ensure that your code style rules are respected.

Contributing

Pull requests are welcome. If you add functionality, then please add unit tests to cover it.

License

MIT © Ben Briggs

stylehacks's People

Contributors

ben-eb avatar greenkeeperio-bot avatar

Watchers

 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.