postcss-loader
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -0,1 +1,4 @@ | ||
## 1.2.2 | ||
* Watch `postcss.config.js` for changes (by Michael Ciniawsky). | ||
## 1.2.1 | ||
@@ -2,0 +5,0 @@ * Fix relative `config` parameter resolving (by Simen Bekkhus). |
@@ -51,2 +51,3 @@ var loaderUtils = require('loader-utils'); | ||
var callback = loader.async(); | ||
var configPath; | ||
@@ -76,2 +77,5 @@ | ||
if ( !config ) config = { }; | ||
if ( config.file ) loader.addDependency(config.file); | ||
var plugins = config.plugins || []; | ||
@@ -78,0 +82,0 @@ |
{ | ||
"name": "postcss-loader", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "PostCSS loader for webpack", | ||
"engines": { | ||
"node": ">=0.12", | ||
"npm": ">=3" | ||
"node": ">=0.12" | ||
}, | ||
@@ -22,7 +21,7 @@ "keywords": [ | ||
"object-assign": "^4.1.0", | ||
"postcss": "^5.2.6", | ||
"postcss-load-config": "^1.0.0" | ||
"postcss": "^5.2.9", | ||
"postcss-load-config": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^3.11.1", | ||
"eslint": "^3.13.1", | ||
"eslint-config-postcss": "^2.0.2", | ||
@@ -32,8 +31,9 @@ "fs-extra": "^1.0.0", | ||
"gulp-eslint": "^3.0.1", | ||
"gulp-jest": "^0.6.0", | ||
"gulp-jest": "^1.0.0", | ||
"jest-cli": "^18.1.0", | ||
"json-loader": "^0.5.4", | ||
"lint-staged": "^3.2.1", | ||
"postcss-js": "^0.1.3", | ||
"lint-staged": "^3.2.6", | ||
"postcss-js": "^0.2.0", | ||
"postcss-safe-parser": "^2.0.0", | ||
"pre-commit": "^1.1.3", | ||
"pre-commit": "^1.2.2", | ||
"raw-loader": "^0.5.1", | ||
@@ -40,0 +40,0 @@ "sugarss": "^0.2.0", |
111
README.md
@@ -28,8 +28,48 @@ # PostCSS for Webpack [![Build Status][ci-img]][ci] | ||
Create `postcss.config.js`: | ||
```js | ||
module.exports = { | ||
plugins: [ | ||
require('postcss-smart-import')({ /* ...options */ }), | ||
require('precss')({ /* ...options */ }), | ||
require('autoprefixer')({ /* ...options */ }) | ||
] | ||
} | ||
``` | ||
You could put different configs in different directories. For example, | ||
global config in `project/postcss.config.js` and override its plugins | ||
in `project/src/legacy/postcss.config.js`. | ||
You can read more about common PostCSS config in | ||
[postcss-load-config](https://github.com/michael-ciniawsky/postcss-load-config). | ||
Add PostCSS Loader to `webpack.config.js`. Put it after `css-loader` | ||
and `style-loader`. But before `sass-loader`, if you use it. | ||
### Webpack 2 | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
'style-loader', | ||
'css-loader?importLoaders=1', | ||
'postcss-loader' | ||
] | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
### Webpack 1 | ||
```js | ||
module.exports = { | ||
module: { | ||
loaders: [ | ||
@@ -49,24 +89,61 @@ { | ||
Then create `postcss.config.js`: | ||
## Options | ||
### Plugins | ||
We recommend to use `postcss.config.js`, but also you can specify plugins | ||
directly in webpack config. | ||
#### Webpack 2 | ||
```js | ||
module.exports = { | ||
plugins: [ | ||
require('postcss-smart-import')({ /* ...options */ }), | ||
require('precss')({ /* ...options */ }), | ||
require('autoprefixer')({ /* ...options */ }) | ||
] | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css/, | ||
use: [ | ||
… | ||
{ | ||
loader: 'postcss-loader', | ||
options: { | ||
plugins: function () { | ||
return [ | ||
require('precss'), | ||
require('autoprefixer') | ||
]; | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
You could put different configs in different directories. For example, | ||
global config in `project/postcss.config.js` and override its plugins | ||
in `project/src/legacy/postcss.config.js`. | ||
#### Webpack 1 | ||
You can read more about common PostCSS config in [postcss-load-config]. | ||
```js | ||
module.exports = { | ||
module: { | ||
loaders: [ | ||
{ | ||
test: /\.css$/, | ||
loaders: [ | ||
… | ||
'postcss-loader' | ||
] | ||
} | ||
] | ||
}, | ||
postcss: () => { | ||
return [ | ||
require('precss'), | ||
require('autoprefixer') | ||
]; | ||
} | ||
} | ||
``` | ||
[postcss-load-config]: https://github.com/michael-ciniawsky/postcss-load-config | ||
## Options | ||
### Syntaxes | ||
@@ -185,2 +262,7 @@ | ||
> If you are using Babel >= v6 you need to do the following in order for the setup to work | ||
> 1. Add [babel-plugin-add-module-exports] to your configuration | ||
> 2. You need to have only one **default** export per style module | ||
If you use JS styles without `postcss-js` parser, you can add `exec` parameter: | ||
@@ -202,2 +284,3 @@ | ||
[postcss-js]: https://github.com/postcss/postcss-js | ||
[babel-plugin-add-module-exports]: https://github.com/59naga/babel-plugin-add-module-exports | ||
@@ -204,0 +287,0 @@ ### Dynamic Config |
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
16013
139
310
15
Updatedpostcss@^5.2.9
Updatedpostcss-load-config@^1.1.0