Consume @import in css recursively
npm install postcss-simple-importConsume @import in css recursively.
* @import node-style modules
* Resolve the module entry according to the style field of package.json rather than main
* Files are imported only once
Type: String
Default: import
@import.Type: Function
Signature: importer(url, from, opts)
* url: @import "url";
* from: the absolute path of the current css file
* opts: the options object
opts.postcssOpts is accessible.
Should return an array of objects (or promises) with the following fields:
from: String required* the resolved file path
source: String optional* the contents of the file
If undefined returned, the importer will be ignored.
Type: Function
Signature: readFile(filename)
Should return a string (or promise) of contents of the file.
It should have glob.hasMagic(url) to check whether globs exist.
Type: Function
Receives the glob string, and an object { cwd: dirname_of_the_processed_file }.
Should return an array (or a promise) of file paths.
Type: true
A promisified version of glob is used.
Type: Function
Receives the import string, and an object { basedir: dirname_of_the_processed_file }.
Should return an absolute file path (or promise).
Type: Object
Passed to custom-resolve to create the resolve function.
``javascript
var resolver = require('custom-resolve')
opts.resolve = promisify(resolver(mix({
packageEntry: 'style',
extensions: '.css',
symlinks: true, // resolve all soft links to their real paths
}, opts.resolve)))
`
Type: Function
Signature: parse(source, from)
Should return the AST object (or promise).
Use the imports event instead.
Type: Function
Signature: onImport(from, imports, postcssOpts)
* from: the css fileimports
* : files directly imported by frompostcssOpts
* : postcssOpts
Type: Object
#### import
Fired right after file path resolved, but before compilation.
Listener signature: fn(importedFile, from, opts)
opts.postcssOpts is accessible.
#### imports
Fired right after compilation.
Listener signature: fn(imports, from, opts)
* imports: Array
opts.postcssOpts is accessible.
Type: Object
Options passed to process(source, postcssOpts)`