Sha256: cae098879fbc2d13c5673192cb189f04d9eec0fd6fa7e3b6ab46328e77c69bfd

Contents?: true

Size: 1.71 KB

Versions: 26

Compression:

Stored size: 1.71 KB

Contents

# stylehacks

> Detect/remove browser hacks from CSS files.


## Install

With [npm](https://npmjs.org/package/stylehacks) 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

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

### Output

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

```css
h1 { _color: red }
```

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

#### options

##### lint

Type: `boolean`  
Default: `false`

If lint mode is enabled, stylehacks will not remove hacks from the CSS; instead,
it will add warnings to `Result#messages`.


### `postcss([ stylehacks(opts) ])`

stylehacks can also be consumed as a PostCSS plugin. See the
[documentation](https://github.com/postcss/postcss#usage) for examples for
your environment.


## 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](http://beneb.info)


[stylelint]: https://github.com/stylelint/stylelint

Version data entries

26 entries across 25 versions & 8 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/stylehacks/README.md
disco_app-0.18.0 test/dummy/node_modules/stylehacks/README.md
disco_app-0.18.2 test/dummy/node_modules/stylehacks/README.md
disco_app-0.16.1 test/dummy/node_modules/stylehacks/README.md
disco_app-0.15.2 test/dummy/node_modules/stylehacks/README.md
disco_app-0.18.4 test/dummy/node_modules/stylehacks/README.md
disco_app-0.18.1 test/dummy/node_modules/stylehacks/README.md
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/stylehacks/README.md
disco_app-0.14.0 test/dummy/node_modules/stylehacks/README.md
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/stylehacks/README.md
tang-0.2.1 spec/tang_app/node_modules/stylehacks/README.md
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/stylehacks/README.md
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/stylehacks/README.md
ruby2js-4.0.4 lib/tasks/testrails/node_modules/stylehacks/README.md
ruby2js-4.0.3 lib/tasks/testrails/node_modules/stylehacks/README.md
tang-0.2.0 spec/tang_app/node_modules/stylehacks/README.md
tang-0.1.0 spec/tang_app/node_modules/stylehacks/README.md
tang-0.0.9 spec/tang_app/node_modules/stylehacks/README.md
enju_library-0.3.8 spec/dummy/node_modules/stylehacks/README.md
jester-data-8.0.0 node_modules/stylehacks/README.md