A rework plugin to read and inline css via @import
JavaScript
Latest commit 071a715 Aug 10, 2015 @kevva kevva Tweaks
Failed to load latest commit information.
test Tweaks Aug 10, 2015
.editorconfig Tweaks Jun 23, 2015
.gitattributes Initial commit Sep 11, 2013
.gitignore Fix file reading Sep 12, 2013
.jshintrc
.travis.yml
changelog.md Tweaks Aug 10, 2015
index.js Tweaks Aug 10, 2015
license Tweaks Aug 10, 2015
package.json
readme.md Tweaks Aug 10, 2015

readme.md

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