You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
1.7 KiB

4 years ago
  1. # stylehacks
  2. > Detect/remove browser hacks from CSS files.
  3. ## Install
  4. With [npm](https://npmjs.org/package/stylehacks) do:
  5. ```
  6. npm install stylehacks --save
  7. ```
  8. ## Example
  9. In its default mode, stylehacks will remove hacks from your CSS file, based on
  10. the browsers that you wish to support.
  11. ### Input
  12. ```css
  13. h1 {
  14. _color: white;
  15. color: rgba(255, 255, 255, 0.5);
  16. }
  17. ```
  18. ### Output
  19. ```css
  20. h1 {
  21. color: rgba(255, 255, 255, 0.5);
  22. }
  23. ```
  24. ## API
  25. ### `stylehacks.detect(node)`
  26. Type: `function`
  27. Returns: `boolean`
  28. This method will take any PostCSS *node*, run applicable plugins depending on
  29. its type, then will return a boolean depending on whether it found any of
  30. the supported hacks. For example, if the `decl` node found below is passed to
  31. the `detect` function, it will return `true`. But if the `rule` node is passed,
  32. it will return `false` instead.
  33. ```css
  34. h1 { _color: red }
  35. ```
  36. ### `stylehacks.process(css, [options]).then(function(result) {})`
  37. #### options
  38. ##### lint
  39. Type: `boolean`
  40. Default: `false`
  41. If lint mode is enabled, stylehacks will not remove hacks from the CSS; instead,
  42. it will add warnings to `Result#messages`.
  43. ### `postcss([ stylehacks(opts) ])`
  44. stylehacks can also be consumed as a PostCSS plugin. See the
  45. [documentation](https://github.com/postcss/postcss#usage) for examples for
  46. your environment.
  47. ## Related
  48. stylehacks works well with your existing PostCSS setup:
  49. * [stylelint] - Comprehensive & modern CSS linter, to ensure that your code
  50. style rules are respected.
  51. ## Contributing
  52. Pull requests are welcome. If you add functionality, then please add unit tests
  53. to cover it.
  54. ## License
  55. MIT © [Ben Briggs](http://beneb.info)
  56. [stylelint]: https://github.com/stylelint/stylelint