This repository has been archived by the owner. It is now read-only.
DEPRECATED, see | Detect/remove browser hacks from CSS files.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 4dd3baa Feb 23, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Also update trailingSlashComma. Feb 22, 2017
.babelrc Tidy up module. Feb 22, 2016
.editorconfig Tidy up module. Feb 22, 2016
.gitignore Add code coverage. Jul 29, 2016
.travis.yml Update to ESLint 3. Jul 6, 2016 Update changelog. Feb 22, 2017
LICENSE-MIT Initial commit. Jul 6, 2015 Tidy up module. Feb 22, 2016
package.json 2.3.2 Feb 22, 2017
usage.txt Tidy up module. Feb 22, 2016

stylehacks Build Status NPM version Dependency Status

Detect/remove browser hacks from CSS files.


With npm do:

npm install stylehacks --save


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


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


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



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) {})



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.


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.


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.


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.


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.


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


MIT © Ben Briggs