https://github.com/fomantic/rework-import
A rework plugin to read and inline css via @import
https://github.com/fomantic/rework-import
Last synced: 4 months ago
JSON representation
A rework plugin to read and inline css via @import
- Host: GitHub
- URL: https://github.com/fomantic/rework-import
- Owner: fomantic
- License: mit
- Fork: true (reworkcss/rework-import)
- Created: 2022-10-27T19:15:09.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-03-01T14:14:35.000Z (about 1 year ago)
- Last Synced: 2025-11-27T09:37:18.411Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 248 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- License: license
Awesome Lists containing this project
README
# rework-import [](https://travis-ci.org/reworkcss/rework-import)
> ### 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
```bash
$ npm install --save rework-import
```
## Usage
```js
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](https://github.com/reworkcss/css#cssparsecode-options)
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`](https://github.com/reworkcss/css-whitespace).
## Example
```css
@import 'foo.css' (min-width: 25em);
body {
background: black;
}
```
yields:
```css
@media (min-width: 25em) {
body {
background: red;
}
h1 {
color: grey;
}
}
body {
background: black;
}
```
## License
MIT © [Jason Campbell](https://github.com/jxson) and [Kevin Mårtensson](http://github.com/kevva)