JSPM

  • Created
  • Published
  • Downloads 14360510
  • Score
    100M100P100Q216968F
  • License MIT

Detect/remove browser hacks from CSS files.

Package Exports

  • stylehacks

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stylehacks) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.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

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