rework-import

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

MIT 13 个版本
安装
npm install rework-import
yarn add rework-import
pnpm add rework-import
bun add rework-import
README

rework-import Build Status

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

版本列表
2.1.0 2015-07-14
2.0.1 2015-01-28
2.0.0 2014-11-27
1.2.1 2014-09-05
1.2.0 2014-07-04
1.1.3 2014-06-27
1.1.2 2014-06-26
1.1.1 2014-06-26
1.1.0 2014-06-25
1.0.0 2014-06-14
0.0.3 2013-08-06
0.0.2 2013-08-06
0.0.1 2013-08-06