Socket
Socket
Sign inDemoInstall

postcss-load-config

Package Overview
Dependencies
14
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 2.0.0

src/index.js

28

CHANGELOG.md

@@ -0,1 +1,29 @@

# Change Log
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
<a name="2.0.0"></a>
# [2.0.0](https://github.com/michael-ciniawsky/postcss-load-config/compare/v1.2.0...v2.0.0) (2018-07-10)
### Bug Fixes
* **package:** `require-from-string` memory leak, updates `cosmiconfig` v2.1.0...4.0.0 (`dependencies`) ([17f9621](https://github.com/michael-ciniawsky/postcss-load-config/commit/17f9621))
* **src/index.js:** clone the config `{Object}` on assignment instead of mutating it ([8669a90](https://github.com/michael-ciniawsky/postcss-load-config/commit/8669a90))
### Features
* **src:** load plugins from the current working directory ([9745bf0](https://github.com/michael-ciniawsky/postcss-load-config/commit/9745bf0))
* **src:** show config file in `err.message` ([4baff47](https://github.com/michael-ciniawsky/postcss-load-config/commit/4baff47))
### BREAKING CHANGES
* **package:** requires `node >= v4.0.0`
* **package:** removes `argv` option (`options.argv`)
* **package:** removes `--config` parsing
<a name="1.2.0"></a>

@@ -2,0 +30,0 @@ # [1.2.0](https://github.com/michael-ciniawsky/postcss-load-config/compare/v1.1.0...v1.2.0) (2017-02-13)

90

package.json
{
"name": "postcss-load-config",
"version": "1.2.0",
"version": "2.0.0",
"description": "Autoload Config for PostCSS",
"engines": { "node": ">=0.12" },
"main": "index.js",
"main": "src/index.js",
"files": [
"src"
],
"engines": {
"node": ">= 4"
},
"scripts": {
"lint": "standard",
"test": "nyc ava -v test/err/index.js test/pkg/index.js test/rc/index.js test/js/**/index.js",
"logs": "standard-changelog -i CHANGELOG.md -w",
"docs": "jsdoc2md index.js > INDEX.md",
"clean": "rm -rf .nyc_output coverage jsdoc-api dmd",
"start": "sudo npm run clean && npm run lint && sudo npm test"
"lint": "standard --env jest",
"test": "jest --verbose --coverage",
"docs": "jsdoc2md src/*.js > DOCS.md",
"clean": "del-cli coverage",
"release": "standard-version"
},
"dependencies": {
"cosmiconfig": "^2.1.0",
"object-assign": "^4.1.0",
"postcss-load-options": "^1.2.0",
"postcss-load-plugins": "^2.3.0"
"cosmiconfig": "^4.0.0",
"import-cwd": "^2.0.0"
},
"devDependencies": {
"ava": "^0.18.1",
"coveralls": "^2.11.16",
"cssnano": "^3.10.0",
"jsdoc-to-markdown": "^3.0.0",
"nyc": "^10.1.0",
"postcss": "^5.2.12",
"postcss-cssnext": "^2.8.0",
"postcss-import": "^9.1.0",
"postcss-nested": "^1.0.0",
"postcss-scss": "^0.4.0",
"postcss-sprites": "^4.2.0",
"standard": "^8.6.0",
"standard-changelog": "0.0.1",
"sugarss": "^0.2.0"
"cssnano": "^4.0.0",
"del-cli": "^1.0.0",
"jest": "^22.0.0",
"jsdoc-to-markdown": "^4.0.0",
"postcss": "^6.0.0",
"postcss-import": "^11.0.0",
"postcss-nested": "^3.0.0",
"standard": "^11.0.0",
"standard-version": "4.0.0",
"sugarss": "^1.0.0"
},
"files": [
"index.js"
],
"keywords": [
"postcss",
"postcss-config"
"postcssrc",
"postcss.config.js"
],
"author": {
"name": "Michael Ciniawky",
"email": "michael.ciniawsky@gmail.com"
},
"author": "Michael Ciniawky <michael.ciniawsky@gmail.com>",
"contributors": [
{
"name": "Mateusz Derks",
"url": "http://ertrzyiks.me"
},
{
"name": "Ryan Dunckel",
"email": "sparty02@gmail.com"
},
{
"name": "Patrick Gilday"
},
{
"name": "Dalton Santos"
}
"Ryan Dunckel",
"Mateusz Derks",
"Dalton Santos",
"Patrick Gilday"
],
"repository": {
"type": "git",
"url": "git+https://github.com/michael-ciniawsky/postcss-load-config.git"
},
"bugs": {
"url": "https://github.com/michael-ciniawsky/postcss-load-config/issues"
},
"repository": "https://github.com/michael-ciniawsky/postcss-load-config.git",
"bugs": "https://github.com/michael-ciniawsky/postcss-load-config/issues",
"homepage": "https://github.com/michael-ciniawsky/postcss-load-config#readme",
"license": "MIT"
}
[![npm][npm]][npm-url]
[![node][node]][node-url]
[![deps][deps]][deps-url]
[![tests][tests]][tests-url]
[![test][test]][test-url]
[![coverage][cover]][cover-url]

@@ -26,14 +26,16 @@ [![code style][style]][style-url]

```
```bash
npm i -S|-D postcss-plugin
```
Install plugins and save them to your ***package.json*** dependencies/devDependencies.
Install all required postcss plugins and save them to your **package.json** `dependencies`/`devDependencies`
Then create a postcss config file by choosing one of the following formats
### `package.json`
Create **`postcss`** section in your projects **`package.json`**.
Create a **`postcss`** section in your projects **`package.json`**
```
App
Project (Root)
|– client

@@ -50,4 +52,2 @@ |– public

"map": false,
"from": "/path/to/src.sss",
"to": "/path/to/dest.css",
"plugins": {

@@ -62,16 +62,16 @@ "postcss-plugin": {}

Create a **`.postcssrc`** file in JSON or YAML format.
Create a **`.postcssrc`** file in JSON or YAML format
It's also allowed to use extensions (**`.postcssrc.json`** or **`.postcssrc.yaml`**). That could help your text editor to properly interpret the file.
> ℹ️ It's recommended to use an extension (e.g **`.postcssrc.json`** or **`.postcssrc.yml`**) instead of `.postcssrc`
```
App
Project (Root)
|– client
|– public
|
|- (.postcssrc|.postcssrc.json|.postcssrc.yaml)
|- (.postcssrc|.postcssrc.json|.postcssrc.yml)
|- package.json
```
**`JSON`**
**`.postcssrc.json`**
```json

@@ -81,4 +81,2 @@ {

"map": false,
"from": "/path/to/src.sss",
"to": "/path/to/dest.css",
"plugins": {

@@ -90,8 +88,6 @@ "postcss-plugin": {}

**`YAML`**
**`.postcssrc.yml`**
```yaml
parser: sugarss
map: false
from: "/path/to/src.sss"
to: "/path/to/dest.css"
plugins:

@@ -101,12 +97,12 @@ postcss-plugin: {}

### `postcss.config.js` or `.postcssrc.js`
### `.postcssrc.js` or `postcss.config.js`
You may need some JavaScript logic to generate your config. For this case you can use a file named **`postcss.config.js`** or **`.postcssrc.js`**.
You may need some logic within your config. In this case create JS file named **`.postcssrc.js`** or **`postcss.config.js`**
```
App
Project (Root)
|– client
|– public
|
|- (postcss.config.js|.postcssrc.js)
|- (.postcssrc.js|postcss.config.js)
|- package.json

@@ -117,2 +113,3 @@ ```

**.postcssrc.js**
```js

@@ -122,4 +119,2 @@ module.exports = {

map: false,
from: '/path/to/src.sss',
to: '/path/to/dest.css',
plugins: {

@@ -131,4 +126,5 @@ 'postcss-plugin': {}

Or export a `{Function}` that returns the config (more about the param `ctx` below)
Or export a `{Function}` that returns the config (more about the `ctx` param below)
**.postcssrc.js**
```js

@@ -138,6 +134,4 @@ module.exports = (ctx) => ({

map: ctx.env === 'development' ? ctx.map : false,
from: ctx.from,
to: ctx.to,
plugins: {
'postcss-plugin': ctx.plugin
'postcss-plugin': ctx.options.plugin
}

@@ -147,11 +141,12 @@ })

Plugins can be loaded in either using an `{Object}` or an `{Array}`.
Plugins can be loaded either using an `{Object}` or an `{Array}`
##### `{Object}`
#### `{Object}`
**.postcssrc.js**
```js
module.exports = (ctx) => ({
module.exports = ({ env }) => ({
...options
plugins: {
'postcss-plugin': ctx.plugin
'postcss-plugin': env === 'production' ? {} : false
}

@@ -161,49 +156,78 @@ })

##### `{Array}`
#### `{Array}`
**.postcssrc.js**
```js
module.exports = (ctx) => ({
module.exports = ({ env }) => ({
...options
plugins: [
require('postcss-plugin')(ctx.plugin)
env === 'production' ? require('postcss-plugin')() : false
]
})
```
> :warning: When using an Array, make sure to `require()` them.
> :warning: When using an `{Array}`, make sure to `require()` each plugin
<h2 align="center">Options</h2>
**`parser`**:
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|[**`to`**](#to)|`{String}`|`undefined`|Destination File Path|
|[**`map`**](#map)|`{String\|Object}`|`false`|Enable/Disable Source Maps|
|[**`from`**](#from)|`{String}`|`undefined`|Source File Path|
|[**`parser`**](#parser)|`{String\|Function}`|`false`|Custom PostCSS Parser|
|[**`syntax`**](#syntax)|`{String\|Function}`|`false`|Custom PostCSS Syntax|
|[**`stringifier`**](#stringifier)|`{String\|Function}`|`false`|Custom PostCSS Stringifier|
### `parser`
**.postcssrc.js**
```js
'parser': 'sugarss'
module.exports = {
parser: 'sugarss'
}
```
**`syntax`**:
### `syntax`
**.postcssrc.js**
```js
'syntax': 'postcss-scss'
module.exports = {
syntax: 'postcss-scss'
}
```
**`stringifier`**:
### `stringifier`
**.postcssrc.js**
```js
'stringifier': 'midas'
module.exports = {
stringifier: 'midas'
}
```
[**`map`**:](https://github.com/postcss/postcss/blob/master/docs/source-maps.md)
### [**`map`**](https://github.com/postcss/postcss/blob/master/docs/source-maps.md)
**.postcssrc.js**
```js
'map': 'inline'
module.exports = {
map: 'inline'
}
```
**`from`**:
> :warning: In most cases `options.from` && `options.to` are set by the third-party which integrates this package (CLI, gulp, webpack). It's unlikely one needs to set/use `options.from` && `options.to` within a config file. Unless you're a third-party plugin author using this module and its Node API directly **dont't set `options.from` && `options.to` yourself**
### `to`
```js
from: 'path/to/src.css'
module.exports = {
to: 'path/to/dest.css'
}
```
**`to`**:
### `from`
```js
to: 'path/to/dest.css'
module.exports = {
from: 'path/to/src.css'
}
```

@@ -213,5 +237,5 @@

### Options
### `{} || null`
**`{} || null`**: Plugin loads with defaults.
The plugin will be loaded with defaults

@@ -221,6 +245,18 @@ ```js

```
> :warning: `{}` must be an **empty** object
**`[Object]`**: Plugin loads with given options.
**.postcssrc.js**
```js
module.exports = {
plugins: {
'postcss-plugin': {} || null
}
}
```
> :warning: `{}` must be an **empty** `{Object}` literal
### `{Object}`
The plugin will be loaded with given options
```js

@@ -230,4 +266,15 @@ 'postcss-plugin': { option: '', option: '' }

**`false`**: Plugin will not be loaded.
**.postcssrc.js**
```js
module.exports = {
plugins: {
'postcss-plugin': { option: '', option: '' }
}
}
```
### `false`
The plugin will not be loaded
```js

@@ -237,12 +284,21 @@ 'postcss-plugin': false

### Order
**.postcssrc.js**
```js
module.exports = {
plugins: {
'postcss-plugin': false
}
}
```
Plugin **order** is determined by declaration in the plugins section.
### `Ordering`
Plugin **execution order** is determined by declaration in the plugins section (**top-down**)
```js
{
plugins: {
'postcss-plugin': {}, // plugins[0]
'postcss-plugin': {}, // plugins[1]
'postcss-plugin': {} // plugins[2]
'postcss-plugin': {}, // [0]
'postcss-plugin': {}, // [1]
'postcss-plugin': {} // [2]
}

@@ -254,4 +310,6 @@ }

When using a function (`postcss.config.js` or `.postcssrc.js`), it is possible to pass context to `postcss-load-config`, which will be evaluated while loading your config. By default `ctx.env (process.env.NODE_ENV)` and `ctx.cwd (process.cwd())` are available.
When using a `{Function}` (`postcss.config.js` or `.postcssrc.js`), it's possible to pass context to `postcss-load-config`, which will be evaluated while loading your config. By default `ctx.env (process.env.NODE_ENV)` and `ctx.cwd (process.cwd())` are available on the `ctx` `{Object}`
> ℹ️ Most third-party integrations add additional properties to the `ctx` (e.g `postcss-loader`). Check the specific module's README for more information about what is available on the respective `ctx`
<h2 align="center">Examples</h2>

@@ -273,3 +331,5 @@

### <img width="80" height="80" src="https://worldvectorlogo.com/logos/nodejs-icon.svg">
<div align="center">
<img width="80" height="80" src="https://worldvectorlogo.com/logos/nodejs-icon.svg">
</div>

@@ -300,3 +360,5 @@ ```json

### <img width="80" height="80" src="https://worldvectorlogo.com/logos/gulp.svg">
<div align="center">
<img width="80" height="80" halign="10" src="https://worldvectorlogo.com/logos/gulp.svg">
</div>

@@ -328,3 +390,5 @@ ```json

### <img width="80" height="80" src="https://worldvectorlogo.com/logos/webpack.svg">
<div align="center">
<img width="80" height="80" src="https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon.svg">
</div>

@@ -338,2 +402,3 @@ ```json

**webpack.config.js**
```js

@@ -344,9 +409,6 @@ module.exports = (env) => ({

{
test: /\.css$/
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: { importLoaders: 1 } }
},
'css-loader',
'postcss-loader'

@@ -366,4 +428,4 @@ ]

<td align="center">
<img width="150 height="150"
src="https://avatars.githubusercontent.com/u/5419992?v=3&s=150">
<img width="150" height="150"
src="https://github.com/michael-ciniawsky.png?v=3&s=150">
<br />

@@ -373,4 +435,4 @@ <a href="https://github.com/michael-ciniawsky">Michael Ciniawsky</a>

<td align="center">
<img width="150 height="150"
src="https://avatars.githubusercontent.com/u/2437969?v=3&s=150">
<img width="150" height="150"
src="https://github.com/ertrzyiks.png?v=3&s=150">
<br />

@@ -390,3 +452,3 @@ <a href="https://github.com/ertrzyiks">Mateusz Derks</a>

<img width="150" height="150"
src="https://avatars.githubusercontent.com/u/1483538?v=3&s=150">
src="https://github.com/sparty02.png?v=3&s=150">
<br />

@@ -397,3 +459,3 @@ <a href="https://github.com/sparty02">Ryan Dunckel</a>

<img width="150" height="150"
src="https://avatars.githubusercontent.com/u/6249643?v=3&s=150">
src="https://github.com/pcgilday.png?v=3&s=150">
<br />

@@ -404,3 +466,3 @@ <a href="https://github.com/pcgilday">Patrick Gilday</a>

<img width="150" height="150"
src="https://avatars.githubusercontent.com/u/5603632?v=3&s=150">
src="https://github.com/daltones.png?v=3&s=150">
<br />

@@ -413,2 +475,3 @@ <a href="https://github.com/daltones">Dalton Santos</a>

[npm]: https://img.shields.io/npm/v/postcss-load-config.svg

@@ -423,12 +486,12 @@ [npm-url]: https://npmjs.com/package/postcss-load-config

[style]: https://img.shields.io/badge/code%20style-standard-yellow.svg
[style-url]: http://standardjs.com/
[test]: http://img.shields.io/travis/michael-ciniawsky/postcss-load-config.svg
[test-url]: https://travis-ci.org/michael-ciniawsky/postcss-load-config
[tests]: http://img.shields.io/travis/michael-ciniawsky/postcss-load-config.svg
[tests-url]: https://travis-ci.org/michael-ciniawsky/postcss-load-config
[cover]: https://coveralls.io/repos/github/michael-ciniawsky/postcss-load-config/badge.svg
[cover-url]: https://coveralls.io/github/michael-ciniawsky/postcss-load-config
[style]: https://img.shields.io/badge/code%20style-standard-yellow.svg
[style-url]: http://standardjs.com/
[chat]: https://img.shields.io/gitter/room/postcss/postcss.svg
[chat-url]: https://gitter.im/postcss/postcss
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc