@fomantic/rework-import

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

A rework plugin to read and inline CSS files via @import

原始使用文档
文档目录9 节
  1. Forked Version using updated dependencies and dropped sourc…
  2. Install
  3. Usage
  4. Options
  5. encoding
  6. path
  7. transform
  8. Example
  9. License

rework-import Build Status

Forked Version using updated dependencies and dropped sourceMap support

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

Import stylesheets using @import and an optional media query

Install

$ npm install --save rework-import

Usage

var data = require('fs').readFileSync('index.css');
var imprt = require('rework-import');
var rework = require('rework');

rework(data)
    .use(imprt({path: 'app/stylesheets'}))
    .toString();

Options

encoding

Type: String
Default: utf8

Use if your CSS is encoded in anything other than UTF-8.

path

Type: Array|String
Default: process.cwd() or __dirname of the rework source

A string or an array of paths in where to look for files.

Note: nested @import will additionally benefit of the relative dirname of imported files.

transform

Type: Function

A function to transform the content of imported files. Takes one argument and should return the modified content. Useful if you use css-whitespace.

Example

@import 'foo.css' (min-width: 25em);

body {
    background: black;
}

yields:

@media (min-width: 25em) {
    body {
        background: red;
    }

    h1 {
        color: grey;
    }
}

body {
    background: black;
}

License

MIT © Jason Campbell and Kevin Mårtensson

版本与发布记录

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

版本发布日期距今
4.3.0latest2026/07/183 个月前
4.2.02026/07/183 个月前
4.1.02025/03/011.7 年前
4.0.02025/03/011.7 年前
3.2.02025/02/081.8 年前
3.1.02024/05/082 年前

关于 @fomantic/rework-import 的常见问题

@fomantic/rework-import 是什么?

A rework plugin to read and inline CSS files via @import

如何安装 @fomantic/rework-import?

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

@fomantic/rework-import 支持 TypeScript 吗?

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

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

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

@fomantic/rework-import 可以商用吗?

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

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

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

@fomantic/rework-import 还在维护吗?

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