JSPM

  • Created
  • Published
  • Downloads 17563307
  • Score
    100M100P100Q215675F
  • License MIT

PostCSS plugin to import CSS files

Package Exports

  • postcss-import

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-import) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

postcss-import Build Status

A PostCSS plugin to import stylesheets using @import and an optional media query.

Installation

npm install postcss-import

Usage

var postcss = require("postcss")
var atImport = require("postcss-import")

var css = postcss()
  .use(atImport())
  .process(cssString)
  .css
@import "foo.css";

@import "bar.css" (min-width: 25em);

body {
  background: black;
}

yields:

/* ... content of foo.css */

@media (min-width: 25em) {
/* ... content of bar.css */
}

body {
  background: black;
}

Options

encoding

Type: String
Default: utf8

Use if your CSS is encoded in anything other than UTF-8.

path

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.

transform

Type: Function
Default: null

A function to transform the content of imported files. Take one argument (file content) & should return the modified content.

Example with some options

var postcss = require("postcss")
var atImport = require("postcss-import")

var css = postcss()
  .use(atImport({
    path: [
      "node_modules",
    ]
    transform: require("css-whitespace")
  }))
  .process(cssString)
  .css

See tests for examples.


Contributing

Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.

git clone https://github.com/postcss/postcss-import.git
git checkout -b patch-1
npm install
npm test

Changelog

License