Import stylesheets using @import and an optional media query. Pass a string or
an array of paths to the path option in where to search for stylesheets.
Handle recursive & relative imports.
$ npm install --save rework-importAs a Rework plugin:
var imprt = require('rework-import');
rework(data)
.use(imprt())
.toString();Example with all options
// using multiples paths
rework(data)
.use(imprt({
path: [
'path/to/your/stylesheets',
'node_modules',
]
transform: require('css-whitespace')
}))
.toString();Type: String
Default: utf8
Use if your CSS is encoded in anything other than UTF-8.
Type: String|Array
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.
Type: Function
Default: null
A function to transform the content of imported files. Take one argument (file content) & should return the modified content.
Useful if you use css-whitespace.
@import "foo.css" (min-width: 25em);
body {
background: black;
}yields:
@media (min-width: 25em) {
body {
background: red;
}
h1 {
color: grey;
}
}
body {
background: black;
}MIT © Jason Campbell and Kevin Mårtensson