项目原始demo,不改动
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

преди 4 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # [postcss][postcss]-discard-comments [![Build Status](https://travis-ci.org/ben-eb/postcss-discard-comments.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/postcss-discard-comments.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-discard-comments.svg)][deps]
  2. > Discard comments in your CSS files with PostCSS.
  3. ## Install
  4. With [npm](https://npmjs.org/package/postcss-discard-comments) do:
  5. ```
  6. npm install postcss-discard-comments --save
  7. ```
  8. ## Example
  9. ### Input
  10. ```css
  11. h1/* heading */{
  12. margin: 0 auto
  13. }
  14. ```
  15. ### Output
  16. ```css
  17. h1 {
  18. margin: 0 auto
  19. }
  20. ```
  21. This module discards comments from your CSS files; by default, it will remove
  22. all regular comments (`/* comment */`) and preserve comments marked as important
  23. (`/*! important */`).
  24. Note that this module does not handle source map comments because they are not
  25. available to it; PostCSS handles this internally, so if they are removed then
  26. you will have to [configure source maps in PostCSS][maps].
  27. [maps]: https://github.com/postcss/postcss/blob/master/docs/source-maps.md
  28. ## API
  29. ### comments([options])
  30. #### options
  31. ##### remove(function)
  32. Type: `function`
  33. Return: `boolean`
  34. Variable: `comment` contains a comment without `/**/`
  35. For each comment, return true to remove, or false to keep the comment.
  36. ```js
  37. function(comment) {}
  38. ```
  39. ```js
  40. var css = '/* headings *//*@ h1 */h1{margin:0 auto}/*@ h2 */h2{color:red}';
  41. console.log(postcss(comments({
  42. remove: function(comment) { return comment[0] == "@"; }
  43. })).process(css).css);
  44. //=> /* headings */h1{margin:0 auto}h2{color:red}
  45. ```
  46. **NOTE:** If you use the `remove` function other options will not be available.
  47. ##### removeAll
  48. Type: `boolean`
  49. Default: `false`
  50. Remove all comments marked as important.
  51. ```js
  52. var css = '/*! heading */h1{margin:0 auto}/*! heading 2 */h2{color:red}';
  53. console.log(postcss(comments({removeAll: true})).process(css).css);
  54. //=> h1{margin:0 auto}h2{color:red}
  55. ```
  56. ##### removeAllButFirst
  57. Type: `boolean`
  58. Default: `false`
  59. Remove all comments marked as important, but the first one.
  60. ```js
  61. var css = '/*! heading */h1{margin:0 auto}/*! heading 2 */h2{color:red}';
  62. console.log(postcss(comments({removeAllButFirst: true})).process(css).css);
  63. //=> /*! heading */h1{margin:0 auto}h2{color:red}
  64. ```
  65. ## Usage
  66. See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
  67. examples for your environment.
  68. ## Contributing
  69. Pull requests are welcome. If you add functionality, then please add unit tests
  70. to cover it.
  71. ## License
  72. MIT © Ben Briggs
  73. [ci]: https://travis-ci.org/ben-eb/postcss-discard-comments
  74. [deps]: https://gemnasium.com/ben-eb/postcss-discard-comments
  75. [npm]: http://badge.fury.io/js/postcss-discard-comments
  76. [postcss]: https://github.com/postcss/postcss