postcss-import
Advanced tools
Comparing version 7.0.0 to 7.1.0
@@ -0,1 +1,7 @@ | ||
# 7.1.0 - 2015-10-19 | ||
- Added: option `addDependencyTo` to make the integration with webpack more | ||
elegant | ||
(ref [postcss-loader#31](https://github.com/postcss/postcss-loader/issues/31)) | ||
# 7.0.0 - 2015-08-25 | ||
@@ -2,0 +8,0 @@ |
25
index.js
@@ -46,7 +46,8 @@ /** | ||
if (typeof options.path === "string") { | ||
options.path = [options.path] | ||
options.path = [ options.path ] | ||
} | ||
return function(styles, result) { | ||
const opts = assign({}, options || {}) | ||
var opts = assign({}, options || {}) | ||
// auto add from option if possible | ||
@@ -96,2 +97,10 @@ if ( | ||
if ( | ||
typeof opts.addDependencyTo === "object" && | ||
typeof opts.addDependencyTo.addDependency === "function" | ||
) { | ||
Object.keys(state.importedFiles) | ||
.forEach(opts.addDependencyTo.addDependency) | ||
} | ||
if (typeof opts.onImport === "function") { | ||
@@ -137,3 +146,3 @@ opts.onImport(Object.keys(state.importedFiles)) | ||
if (atRule.nodes) { | ||
result.warn(warnNodesMessage, {node: atRule}) | ||
result.warn(warnNodesMessage, { node: atRule }) | ||
} | ||
@@ -274,3 +283,3 @@ if (options.glob && glob.hasMagic(atRule.params)) { | ||
// save | ||
state.ignoredAtRules.push([atRule, parsedAtImport]) | ||
state.ignoredAtRules.push([ atRule, parsedAtImport ]) | ||
@@ -357,3 +366,3 @@ // detach | ||
if (fileContent.trim() === "") { | ||
result.warn(resolvedFilename + " is empty", {node: atRule}) | ||
result.warn(resolvedFilename + " is empty", { node: atRule }) | ||
detach(atRule) | ||
@@ -448,3 +457,3 @@ return resolvedPromise | ||
wrapper.nodes = newNodes | ||
newNodes = [wrapper] | ||
newNodes = [ wrapper ] | ||
} | ||
@@ -462,3 +471,3 @@ else if (newNodes && newNodes.length) { | ||
var nodes = atRule.parent.nodes | ||
nodes.splice.apply(nodes, [nodes.indexOf(atRule), 0].concat(newNodes)) | ||
nodes.splice.apply(nodes, [ nodes.indexOf(atRule), 0 ].concat(newNodes)) | ||
detach(atRule) | ||
@@ -499,3 +508,3 @@ } | ||
paths: paths, | ||
extensions: [".css"], | ||
extensions: [ ".css" ], | ||
packageFilter: function processPackage(pkg) { | ||
@@ -502,0 +511,0 @@ pkg.main = pkg.style || "index.css" |
{ | ||
"name": "postcss-import", | ||
"version": "7.0.0", | ||
"version": "7.1.0", | ||
"description": "PostCSS plugin to import CSS files", | ||
@@ -15,6 +15,3 @@ "keywords": [ | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/postcss/postcss-import.git" | ||
}, | ||
"repository": "https://github.com/postcss/postcss-import.git", | ||
"files": [ | ||
@@ -37,4 +34,43 @@ "index.js" | ||
"scripts": { | ||
"test": "eslint . && tape test" | ||
"eslint": "eslint .", | ||
"tape": "tape test", | ||
"test": "npm run eslint && npm run tape" | ||
}, | ||
"eslintConfig": { | ||
"extends": "eslint:recommended", | ||
"ecmaFeatures": { | ||
"modules": true, | ||
"experimentalObjectRestSpread": true | ||
}, | ||
"env": { | ||
"es6": true, | ||
"node": true | ||
}, | ||
"rules": { | ||
"indent": [ 2, 2 ], | ||
"max-len": [ 2, 80, 4 ], | ||
"no-multiple-empty-lines": [ 2, { "max": 1 } ], | ||
"quotes": [ 2, "double" ], | ||
"semi": [ 2, "never" ], | ||
"comma-dangle": [ 2, "always-multiline" ], | ||
"comma-style": [ 2, "last" ], | ||
"brace-style": [ 2, "stroustrup" ], | ||
"dot-location": [ 2, "property" ], | ||
"computed-property-spacing": [ 2, "never" ], | ||
"object-curly-spacing": [ 2, "always" ], | ||
"array-bracket-spacing": [ 2, "always" ], | ||
"space-after-keywords": [ 2, "always" ], | ||
"space-before-blocks": [ 2, "always" ], | ||
"space-before-function-paren": [ 2, "never" ], | ||
"space-in-parens": [ 2, "never" ], | ||
"space-unary-ops": [ 2, { "words": true, "nonwords": false } ], | ||
"spaced-comment": [ 2, "always" ], | ||
"one-var": [ 2, "never" ], | ||
"no-bitwise": [ 2 ], | ||
"prefer-const": [ 2 ] | ||
} | ||
} | ||
} |
@@ -6,3 +6,7 @@ # 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) | ||
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()`), `node_modules`, `web_modules`, `bower_components` or local modules. | ||
To resolve path of an `@import` rule, it can look into root directory | ||
(by default `process.cwd()`), `node_modules`, `web_modules`, `bower_components` | ||
or local modules. | ||
_When importing a module, it will looks for `index.css` or file referenced in | ||
`package.json` in the `style` field._ | ||
You can also provide manually multiples paths where to look at. | ||
@@ -12,2 +16,3 @@ | ||
- **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, | ||
@@ -165,2 +170,20 @@ which will allow you to adjust assets `url()` (or even inline them) after inlining imported files. | ||
#### `addDependencyTo` | ||
Type: `Function` | ||
Default: null | ||
Allow to generate and call a callback that take one argument, the object from | ||
which you need to call `addDependency` from. | ||
Called whenever a file is imported, handy in a webpack workflow. | ||
It's equivalent to `onImport` with the following code: | ||
```js | ||
{ | ||
onImport: function (files) { | ||
files.forEach(this.addDependency) | ||
}.bind(obj) // obj = the argument you should pass to `addDependencyTo()` | ||
} | ||
``` | ||
#### Example with some options | ||
@@ -183,15 +206,10 @@ | ||
## Contributing | ||
## CONTRIBUTING | ||
Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature. | ||
* ⇄ Pull requests and ★ Stars are always welcome. | ||
* For bugs and feature requests, please create an issue. | ||
* Pull requests must be accompanied by passing automated tests (`$ npm test`). | ||
```console | ||
$ git clone https://github.com/postcss/postcss-import.git | ||
$ git checkout -b patch-1 | ||
$ npm install | ||
$ npm test | ||
``` | ||
## [Changelog](CHANGELOG.md) | ||
## [License](LICENSE) |
Sorry, the diff of this file is not supported yet
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
28147
511
212
2