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.

101 lines
4.1 KiB

4 years ago
  1. # rework [![Build Status](https://travis-ci.org/reworkcss/rework.png)](https://travis-ci.org/reworkcss/rework)
  2. CSS manipulations built on [`css`](https://github.com/reworkcss/css), allowing
  3. you to automate vendor prefixing, create your own properties, inline images,
  4. anything you can imagine!
  5. Please refer to [`css`](https://github.com/reworkcss/css) for AST documentation
  6. and to report parser/stringifier issues.
  7. ## Installation
  8. $ npm install rework
  9. ## Usage
  10. ```js
  11. var rework = require('rework');
  12. var pluginA = require('pluginA');
  13. var pluginB = require('pluginB');
  14. rework('body { font-size: 12px; }', { source: 'source.css' })
  15. .use(pluginA)
  16. .use(pluginB)
  17. .toString({ sourcemap: true })
  18. ```
  19. ## API
  20. ### rework(code, [options])
  21. Accepts a CSS string and returns a new `Rework` instance. The `options` are
  22. passed directly to `css.parse`.
  23. ### Rework#use(fn)
  24. Use the given plugin `fn`. A rework "plugin" is simply a function accepting the
  25. stylesheet root node and the `Rework` instance.
  26. ### Rework#toString([options])
  27. Returns the string representation of the manipulated CSS. The `options` are
  28. passed directly to `css.stringify`.
  29. Unlike `css.stringify`, if you pass `sourcemap: true` a string will still be
  30. returned, with the source map inlined. Also use `sourcemapAsObject: true` if
  31. you want the `css.stringify` return value.
  32. ## Plugins
  33. Rework has a rich collection of plugins and mixins. Browse all the [Rework
  34. plugins](https://www.npmjs.org/search?q=rework) available on npm.
  35. Plugins of particular note:
  36. - [at2x](https://github.com/reworkcss/rework-plugin-at2x/) – serve high resolution images
  37. - [calc](https://github.com/reworkcss/rework-calc) – resolve simple `calc()` expressions
  38. - [colors](https://github.com/reworkcss/rework-plugin-colors/) – color helpers like `rgba(#fc0, .5)`
  39. - [ease](https://github.com/reworkcss/rework-plugin-ease/) – several additional easing functions
  40. - [extend](https://github.com/reworkcss/rework-inherit/) – `extend: selector` support
  41. - [function](https://github.com/reworkcss/rework-plugin-function/) – user-defined CSS functions
  42. - [import](https://github.com/reworkcss/rework-import) – read and inline CSS via `@import`
  43. - [inline](https://github.com/reworkcss/rework-plugin-inline) – inline assets as data URIs
  44. - [mixin](https://github.com/reworkcss/rework-plugin-mixin/) – custom property logic with mixins
  45. - [npm](https://github.com/reworkcss/rework-npm) - inline CSS via `@import` using node's module resolver
  46. - [references](https://github.com/reworkcss/rework-plugin-references/) – property references like `height: @width`
  47. - [url](https://github.com/reworkcss/rework-plugin-url/) – rewrite `url()`s with a given function
  48. - [variables](https://github.com/reworkcss/rework-vars/) – W3C-style variables
  49. ## Built with rework
  50. - [styl](https://github.com/visionmedia/styl)
  51. - [rework-pure-css](https://github.com/ianstormtaylor/rework-pure-css)
  52. - [rework-suit](https://github.com/suitcss/rework-suit)
  53. - [resin](https://github.com/topcoat/resin)
  54. - [Myth](https://github.com/segmentio/myth)
  55. ## License
  56. (The MIT License)
  57. Copyright (c) 2012–2013 TJ Holowaychuk <tj@vision-media.ca>
  58. Copyright (c) 2014 Contributors
  59. Permission is hereby granted, free of charge, to any person obtaining a copy of
  60. this software and associated documentation files (the 'Software'), to deal in
  61. the Software without restriction, including without limitation the rights to
  62. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  63. of the Software, and to permit persons to whom the Software is furnished to do
  64. so, subject to the following conditions:
  65. The above copyright notice and this permission notice shall be included in all
  66. copies or substantial portions of the Software.
  67. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  68. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  69. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  70. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  71. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  72. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  73. SOFTWARE.