postcss-import
Advanced tools
Comparing version 11.0.0 to 11.1.0
@@ -0,1 +1,5 @@ | ||
# 11.1.0 - 2018-02-10 | ||
- Added: `filter` option | ||
# 11.0.0 - 2017-09-16 | ||
@@ -2,0 +6,0 @@ |
43
index.js
@@ -112,2 +112,3 @@ "use strict" | ||
// Strip additional statements. | ||
bundle.forEach(stmt => { | ||
@@ -144,2 +145,7 @@ if (stmt.type === "import") { | ||
if (options.filter && !options.filter(stmt.uri)) { | ||
// rejected by filter | ||
return | ||
} | ||
return resolveImportId(result, stmt, options, state) | ||
@@ -240,25 +246,22 @@ }) | ||
return processContent( | ||
result, | ||
content, | ||
filename, | ||
options | ||
).then(importedResult => { | ||
const styles = importedResult.root | ||
result.messages = result.messages.concat(importedResult.messages) | ||
return processContent(result, content, filename, options).then( | ||
importedResult => { | ||
const styles = importedResult.root | ||
result.messages = result.messages.concat(importedResult.messages) | ||
if (options.skipDuplicates) { | ||
const hasImport = styles.some(child => { | ||
return child.type === "atrule" && child.name === "import" | ||
}) | ||
if (!hasImport) { | ||
// save hash files to skip them next time | ||
if (!state.hashFiles[content]) state.hashFiles[content] = {} | ||
state.hashFiles[content][media] = true | ||
if (options.skipDuplicates) { | ||
const hasImport = styles.some(child => { | ||
return child.type === "atrule" && child.name === "import" | ||
}) | ||
if (!hasImport) { | ||
// save hash files to skip them next time | ||
if (!state.hashFiles[content]) state.hashFiles[content] = {} | ||
state.hashFiles[content][media] = true | ||
} | ||
} | ||
// recursion: import @import from imported file | ||
return parseStyles(result, styles, options, state, media) | ||
} | ||
// recursion: import @import from imported file | ||
return parseStyles(result, styles, options, state, media) | ||
}) | ||
) | ||
}) | ||
@@ -265,0 +268,0 @@ } |
{ | ||
"name": "postcss-import", | ||
"version": "11.0.0", | ||
"version": "11.1.0", | ||
"description": "PostCSS plugin to import CSS files", | ||
@@ -27,5 +27,5 @@ "keywords": [ | ||
"devDependencies": { | ||
"ava": "^0.22.0", | ||
"eslint": "^4.5.0", | ||
"eslint-config-i-am-meticulous": "^6.0.1", | ||
"ava": "^0.25.0", | ||
"eslint": "^4.16.0", | ||
"eslint-config-i-am-meticulous": "^8.0.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
@@ -35,3 +35,3 @@ "eslint-plugin-prettier": "^2.2.0", | ||
"postcss-scss": "^1.0.0", | ||
"prettier": "^1.3.1", | ||
"prettier": "1.10.2", | ||
"sugarss": "^1.0.0" | ||
@@ -38,0 +38,0 @@ }, |
@@ -6,3 +6,5 @@ # postcss-import | ||
[![Version](https://img.shields.io/npm/v/postcss-import.svg)](https://github.com/postcss/postcss-import/blob/master/CHANGELOG.md) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/postcss/postcss-import.svg)](https://greenkeeper.io/) | ||
> [PostCSS](https://github.com/postcss/postcss) plugin to transform `@import` | ||
@@ -37,2 +39,4 @@ rules by inlining content. | ||
(which use this plugin under the hood). | ||
- Imports which are not modified (by `options.filter` or because they are remote | ||
imports) are moved to the top of the output. | ||
- **This plugin attempts to follow the CSS `@import` spec**; `@import` | ||
@@ -113,2 +117,10 @@ statements must precede all other statements (besides `@charset`). | ||
### `filter` | ||
Type: `Function` | ||
Default: `() => true` | ||
Only transform imports for which the test function returns `true`. Imports for | ||
which the test function returns `false` will be left as is. The function gets | ||
the path to import as an argument and should return a boolean. | ||
#### `root` | ||
@@ -115,0 +127,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33896
446
233