包详细信息

rework-import

reworkcss83.1kMIT2.1.0

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

css, import, media, rework

自述文件

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.0.0 / 2014-11-27

  • Use url-regex to check for @imports containing URLs
  • Update parse-import to 2.0.0
  • Major improvements to code and tests

1.2.0 / 2014-07-04

  • Update css to 2.0.0 (ref)

1.1.3 / 2014-06-27

  • Fix a path stack issue

1.1.2 / 2014-06-26

  • Drop graceful-fs to allow browser usage (ref)

1.1.1 / 2014-06-26

  • Ignore protocol base URL

1.1.0 / 2014-06-25

  • Better automatic path (using rework/css.parse source option)
  • Better stack trace
  • transform option (mainly to use css-whitespace)

1.0.0 / 2014-06-14

Merge with rework-inline bring the following:

  • Support media queries
  • Add encoding option
  • Use find-file to lookup imports
  • Automated tests
  • Relative @import
  • Better error reporting

0.0.3 / 2013-08-07

  • Fix unused referenced package

0.0.2 / 2013-08-07

  • Allow nested imports

0.0.1 / 2013-08-06

Initial release