postcss-simple-import
Consume @import in css recursively
Last updated 5 years ago by zoubin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install postcss-simple-import 
SYNC missed versions from official npm registry.

postcss-simple-import

version status coverage dependencies devDependencies node

Consume @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

Options

atRule

Specify the name of at-rules to be processed.

Type: String

Default: import

importer

Specify how to load files when processing @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.

cache

File contents cache.

readFile

Specify how to read file contents.

Type: Function

Signature: readFile(filename)

Should return a string (or promise) of contents of the file.

glob

Specify how to resolve globs.

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.

resolve

Specify how to resolve file paths.

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.

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)))

parse

Specify how to build an AST from the source.

Type: Function

Signature: parse(source, from)

Should return the AST object (or promise).

onImport

Deprecated

Use the imports event instead.

Type: Function

Signature: onImport(from, imports, postcssOpts)

  • from: the css file
  • imports: files directly imported by from
  • postcssOpts: postcssOpts

on

Event listeners.

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.

postcssOpts

Type: Object

Options passed to process(source, postcssOpts)

Current Tags

  • 3.0.0                                ...           latest (5 years ago)

8 Versions

  • 3.0.0                                ...           5 years ago
  • 2.2.0                                ...           5 years ago
  • 2.1.4                                ...           5 years ago
  • 2.1.3                                ...           5 years ago
  • 2.1.0                                ...           5 years ago
  • 2.0.1                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (6)
Dev Dependencies (2)

Copyright 2014 - 2017 © taobao.org |