@fomantic/rework

中文文档
3.2.0发布于 2026/07/18MITCommonJS近 30 天下载 2.3万

Plugin framework for CSS preprocessing

原始使用文档
文档目录10 节
  1. Forked Version using updated dependencies and dropped sourc…
  2. Installation
  3. Usage
  4. API
  5. rework(code, [options])
  6. Rework#use(fn)
  7. Rework#toString([options])
  8. Plugins
  9. Built with rework
  10. License

rework Build Status

Forked Version using updated dependencies and dropped sourceMap support

Original repo at https://github.com/reworkcss/rework

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()

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.

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.

版本与发布记录

@fomantic/rework 共发布 5 个版本,首次发布于 2022/10/28;过去 12 个月发布了 2 个版本。

版本发布日期距今
3.2.0latest2026/07/183 个月前
3.1.02026/07/183 个月前
3.0.02025/03/011.7 年前
2.1.02024/05/082 年前
2.0.02022/10/284 年前

关于 @fomantic/rework 的常见问题

@fomantic/rework 是什么?

Plugin framework for CSS preprocessing

如何安装 @fomantic/rework?

在项目目录运行 npm install @fomantic/rework,或使用 pnpm add / yarn add / bun add。

@fomantic/rework 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fomantic__rework 是否存在。

@fomantic/rework 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@fomantic/rework 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.18.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fomantic/rework 可以商用吗?

@fomantic/rework 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fomantic/rework 的下载量有多少?

根据 npm 官方下载统计,@fomantic/rework 在 2026/10/15 – 2026/11/13 这 30 天内被下载 22,854 次,日均约 762 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fomantic/rework 还在维护吗?

最新版本 3.2.0 发布于 2026/07/18(3 个月前);至今共发布 5 个版本,其中过去 12 个月发布了 2 个;首次发布于 2022/10/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。