• Stars
    star
    2,761
  • Rank 16,495 (Top 0.4 %)
  • Language
    JavaScript
  • Created over 12 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Plugin framework for CSS preprocessing in Node.js

rework Build Status

CSS manipulations built on css, allowing you to automate vendor prefixing, create your own properties, inline images, anything you can imagine!

Please refer to css for AST documentation and to report parser/stringifier issues.

Installation

$ npm install rework

Usage

var rework = require('rework');
var pluginA = require('pluginA');
var pluginB = require('pluginB');

rework('body { font-size: 12px; }', { source: 'source.css' })
  .use(pluginA)
  .use(pluginB)
  .toString({ sourcemap: true })

API

rework(code, [options])

Accepts a CSS string and returns a new Rework instance. The options are passed directly to css.parse.

Rework#use(fn)

Use the given plugin fn. A rework "plugin" is simply a function accepting the stylesheet root node and the Rework instance.

Rework#toString([options])

Returns the string representation of the manipulated CSS. The options are passed directly to css.stringify.

Unlike css.stringify, if you pass sourcemap: true a string will still be returned, with the source map inlined. Also use sourcemapAsObject: true if you want the css.stringify return value.

Plugins

Rework has a rich collection of plugins and mixins. Browse all the Rework plugins available on npm.

Plugins of particular note:

  • at2x – serve high resolution images
  • calc – resolve simple calc() expressions
  • colors – color helpers like rgba(#fc0, .5)
  • ease – several additional easing functions
  • extend – extend: selector support
  • function – user-defined CSS functions
  • import – read and inline CSS via @import
  • inline – inline assets as data URIs
  • mixin – custom property logic with mixins
  • npm - inline CSS via @import using node's module resolver
  • references – property references like height: @width
  • url – rewrite url()s with a given function
  • variables – W3C-style variables

Built with rework

License

(The MIT License)

Copyright (c) 2012–2013 TJ Holowaychuk [email protected]

Copyright (c) 2014 Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

css

CSS parser / stringifier for Node.js
CSS
1,573
star
2

css-parse

CSS parser for Node.js
JavaScript
308
star
3

rework-npm

Import CSS from npm modules using rework
JavaScript
87
star
4

rework-vars

W3C-style CSS variables syntax for Rework
JavaScript
63
star
5

css-whitespace

Convert whitespace significant CSS to valid CSS
CSS
62
star
6

css-stringify

CSS stringifier using the AST from 'css.parse'
JavaScript
55
star
7

css-value

CSS property value parser
JavaScript
41
star
8

rework-inherit

Inherit rules from other selectors
JavaScript
37
star
9

rework-mixins

CSS mixins for rework
JavaScript
34
star
10

rework-plugin-url

url() plugin for rework, formerly included in core
JavaScript
25
star
11

rework-import

A rework plugin to read and inline css via @import
JavaScript
23
star
12

rework-custom-media

W3C-style custom media queries
JavaScript
22
star
13

rework-calc

A calc() plugin for Rework
JavaScript
18
star
14

rework-plugin-at2x

at2x() plugin for rework, formerly included in core
JavaScript
15
star
15

rework-breakpoints

Media Query breakpoint configuration plugin for Rework
JavaScript
15
star
16

rework-ie-limits

Rework plugin to check if CSS contains more selectors than allowed by IE < 10's selector limit
JavaScript
13
star
17

rework-plugin-inline

inline() plugin for rework, formerly included in core
JavaScript
12
star
18

rework-plugin-mixin

mixin() plugin for rework, formerly included in core
JavaScript
11
star
19

rework-plugin-function

function() plugin for rework, formerly included in core
JavaScript
10
star
20

rework-visit

Rework declaration visitor for plugins
JavaScript
10
star
21

rework-move-media

Rework plugin to combine and move Media Queries to the end of the CSS file
JavaScript
9
star
22

rework-variables

$-style CSS variables for Rework
JavaScript
7
star
23

rework-plugin-ease

ease() plugin for rework, formerly included in core
JavaScript
7
star
24

rework-plugin-colors

colors() plugin for rework, formerly included in core
JavaScript
7
star
25

rework-plugin-prefix-selectors

prefixSelectors() plugin for rework, formerly included in core
JavaScript
5
star
26

rework-plugin-references

references() plugin for rework, formerly included in core
JavaScript
4
star
27

split-media

Split your style sheet by @media queries
JavaScript
3
star
28

rework-hwb

Rework plugin for hwb color functions
JavaScript
2
star
29

rework-mixin-opacity

Rework mixin to insert IE 8's opacity filter after any CSS 'opacity' declaration
JavaScript
1
star