Skip to content

Commit

Permalink
8.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MoOx committed Jan 27, 2016
1 parent 5444e79 commit 214844d
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 39 deletions.
48 changes: 29 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
- Removed: async mode/option
([#107](https://github.com/postcss/postcss-import/pull/107))
- Removed: "bower_components" not supported by default anymore, use "path" option to add it back
([#116](https://github.com/postcss/postcss-import/pull/116))
- Changed: custom resolve has more responsibility for paths resolving.
See [resolve option](https://github.com/postcss/postcss-import#resolve) for more information about this change
([#116](https://github.com/postcss/postcss-import/pull/116))
- Added: custom resolve function can return array of paths
([#120](https://github.com/postcss/postcss-import/pull/120))
- Added: custom syntax in imported files support
([#130](https://github.com/postcss/postcss-import/pull/130))
- Added: support custom `load` option
([#144](https://github.com/postcss/postcss-import/pull/144))
- Removed: `encoding` option.
([#144](https://github.com/postcss/postcss-import/pull/144))
# 8.0.0 - 2015-01-27

Encoding can be specified in custom `load` option
- Removed: async mode/option (now async by default)
([#107](https://github.com/postcss/postcss-import/pull/107))
- Removed: "bower_components" not supported by default anymore,
use "path" option to add it back
- Removed: `encoding` option. Encoding can be specified in custom `load` option

```js
postcssImport({
Expand All @@ -23,6 +13,7 @@ postcssImport({
}
})
```
([#144](https://github.com/postcss/postcss-import/pull/144))

- Removed: glob support
([#146](https://github.com/postcss/postcss-import/pull/146))
Expand All @@ -37,12 +28,31 @@ postcssImport({
})
```

- Changed: support promise in `transform` option and `undefined` result will be skipped
([#116](https://github.com/postcss/postcss-import/pull/116))
- Changed: custom resolve has more responsibility for paths resolving.
See [resolve option](https://github.com/postcss/postcss-import#resolve)
for more information about this change
([#116](https://github.com/postcss/postcss-import/pull/116))
- Changed: support promise in `transform` option and `undefined` result will be
skipped
([#147](https://github.com/postcss/postcss-import/pull/147))
- Changed: `options.plugins` are applied to unprocessed ast before imports
detecting
([157](https://github.com/postcss/postcss-import/pull/157))
- Added: custom resolve function can return array of paths
([#120](https://github.com/postcss/postcss-import/pull/120))
- Added: custom syntax in imported files support
([#130](https://github.com/postcss/postcss-import/pull/130))
- Added: support custom `load` option
([#144](https://github.com/postcss/postcss-import/pull/144))
- Added: detect css extension in package.json `main` field
([153](https://github.com/postcss/postcss-import/pull/153))
- Changed: `options.plugins` are applied to unprocessed ast before imports detecting
([157](https://github.com/postcss/postcss-import/pull/157))

**Note:**
_If you miss options/default behavior (glob etc), a new plugin will handle all
those things.
Please follow issue [#145](https://github.com/postcss/postcss-import/issues/145)
_

# 7.1.3 - 2015-11-05

Expand Down
57 changes: 39 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
# postcss-import [![Travis Build Status](https://travis-ci.org/postcss/postcss-import.svg)](https://travis-ci.org/postcss/postcss-import) [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/u8l6u3lr6s5u5tpi?svg=true)](https://ci.appveyor.com/project/MoOx/postcss-import)
# postcss-import

> [PostCSS](https://github.com/postcss/postcss) plugin to transform `@import` rules by inlining content.
[![Unix Build status](https://img.shields.io/travis/postcss/postcss-import/master.svg?branch=master&label=unix%20build)](https://travis-ci.org/postcss/postcss-import)
[![Windows Build status](https://img.shields.io/appveyor/ci/MoOx/postcss-import/master.svg?label=window%20build)](https://ci.appveyor.com/project/MoOx/postcss-import/branch/master)
[![Version](https://img.shields.io/npm/v/postcss-import.svg)](https://github.com/postcss/postcss-import/blob/master/CHANGELOG.md)


> [PostCSS](https://github.com/postcss/postcss) plugin to transform `@import`
rules by inlining content.

This plugin can consume local files, node modules or bower packages.
To resolve path of an `@import` rule, it can look into root directory
(by default `process.cwd()`), `web_modules`, `node_modules`
or local modules.
_When importing a module, it will looks for `index.css` or file referenced in
`package.json` in the `style` field._
`package.json` in the `style` or `main` fields._
You can also provide manually multiples paths where to look at.

**Notes:**

- **This plugin should probably be used as the first plugin of your list. This way, other plugins will work on the AST as if there were only a single file to process, and will probably work as you can expect**.
- This plugin works great with [postcss-url](https://github.com/postcss/postcss-url) plugin,
which will allow you to adjust assets `url()` (or even inline them) after inlining imported files.
- In order to optimize output, **this plugin will only import a file once** on a given scope (root, media query...).
Tests are made from the path & the content of imported files (using a hash table).
- **This plugin should probably be used as the first plugin of your list.
This way, other plugins will work on the AST as if there were only a single file
to process, and will probably work as you can expect**.
- This plugin works great with
[postcss-url](https://github.com/postcss/postcss-url) plugin,
which will allow you to adjust assets `url()` (or even inline them) after
inlining imported files.
- In order to optimize output, **this plugin will only import a file once** on
a given scope (root, media query...).
Tests are made from the path & the content of imported files (using a hash
table).
If this behavior is not what you want, look at `skipDuplicates` option

## Installation
Expand All @@ -27,7 +39,9 @@ $ npm install postcss-import

## Usage

If your stylesheets are not in the same place where you run postcss (`process.cwd()`), you will need to use `from` option to make relative imports work from input dirname.
If your stylesheets are not in the same place where you run postcss
(`process.cwd()`), you will need to use `from` option to make relative imports
work from input dirname.

```js
// dependencies
Expand Down Expand Up @@ -55,7 +69,7 @@ postcss()
Using this `input.css`:

```css
/* can consume `node_modules`, `web_modules`, `bower_components` or local modules */
/* can consume `node_modules`, `web_modules` or local modules */
@import "cssrecipes-defaults"; /* == @import "./node_modules/cssrecipes-defaults/index.css"; */
@import "normalize.css"; /* == @import "./node_modules/normalize.css/normalize.css"; */

Expand Down Expand Up @@ -92,10 +106,13 @@ Checkout [tests](test) for more examples.
#### `root`

Type: `String`
Default: `process.cwd()` or _dirname of [the postcss `from`](https://github.com/postcss/postcss#node-source)_
Default: `process.cwd()` or _dirname of
[the postcss `from`](https://github.com/postcss/postcss#node-source)_

Define the root where to resolve path (eg: place where `node_modules` are). Should not be used that much.
_Note: nested `@import` will additionally benefit of the relative dirname of imported files._
Define the root where to resolve path (eg: place where `node_modules` are).
Should not be used that much.
_Note: nested `@import` will additionally benefit of the relative dirname of
imported files._

#### `path`

Expand All @@ -109,30 +126,33 @@ A string or an array of paths in where to look for files.
Type: `Function`
Default: `null`

A function to transform the content of imported files. Take one argument (file content) and should return the modified content or promise with it.
A function to transform the content of imported files. Take one argument (file
content) and should return the modified content or promise with it.
`undefined` result will be skipped.

#### `plugins`

Type: `Array`
Default: `undefined`

An array of plugins to be applied on each imported file.
An array of plugins to be applied on each imported files.

#### `onImport`

Type: `Function`
Default: `null`

Function called after the import process. Take one argument (array of imported files).
Function called after the import process. Take one argument (array of imported
files).

#### `resolve`

Type: `Function`
Default: `null`

You can overwrite the default path resolving way by setting this option.
This function gets `(id, basedir, importOptions)` arguments and returns full path, array of paths or promise resolving paths.
This function gets `(id, basedir, importOptions)` arguments and returns full
path, array of paths or promise resolving paths.
You can use [resolve](https://github.com/substack/node-resolve) for that.

#### `load`
Expand All @@ -141,7 +161,8 @@ Type: `Function`
Default: null

You can overwrite the default loading way by setting this option.
This function gets `(filename, importOptions)` arguments and returns content or promised content.
This function gets `(filename, importOptions)` arguments and returns content or
promised content.

#### `skipDuplicates`

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-import",
"version": "7.1.3",
"version": "8.0.0",
"description": "PostCSS plugin to import CSS files",
"keywords": [
"css",
Expand All @@ -27,12 +27,14 @@
"ava": "^0.11.0",
"eslint": "^1.10.3",
"eslint-config-i-am-meticulous": "^2.0.0",
"npmpub": "^3.0.1",
"postcss-scss": "^0.1.3"
},
"scripts": {
"lint": "eslint .",
"pretest": "npm run lint",
"test": "ava"
"test": "ava",
"release": "npmpub"
},
"eslintConfig": {
"extends": "eslint-config-i-am-meticulous/es5"
Expand Down

0 comments on commit 214844d

Please sign in to comment.