postcss-loader
Advanced tools
Comparing version 0.9.1 to 0.10.0
@@ -0,1 +1,4 @@ | ||
## 0.10.0 | ||
* Add `sourceMap` parameter to force inline maps (by 雪狼). | ||
## 0.9.1 | ||
@@ -2,0 +5,0 @@ * Fix plugin in simple array config. |
@@ -14,3 +14,3 @@ var loaderUtils = require('loader-utils'); | ||
map: { | ||
inline: false, | ||
inline: params.sourceMap === 'inline', | ||
annotation: false | ||
@@ -17,0 +17,0 @@ } |
{ | ||
"name": "postcss-loader", | ||
"version": "0.9.1", | ||
"version": "0.10.0", | ||
"description": "PostCSS loader for webpack", | ||
@@ -10,4 +10,4 @@ "keywords": ["webpack", "loader", "css", "postcss", "postcss-runner"], | ||
"dependencies": { | ||
"loader-utils": "^0.2.14", | ||
"postcss": "^5.0.19" | ||
"loader-utils": "^0.2.15", | ||
"postcss": "^5.1.2" | ||
}, | ||
@@ -18,7 +18,7 @@ "devDependencies": { | ||
"webpack-stream": "3.2.0", | ||
"gulp-eslint": "2.0.0", | ||
"gulp-eslint": "3.0.1", | ||
"json-loader": "0.5.4", | ||
"raw-loader": "0.5.1", | ||
"postcss-js": "0.1.2", | ||
"gulp-mocha": "2.2.0", | ||
"postcss-js": "0.1.3", | ||
"gulp-mocha": "3.0.1", | ||
"fs-extra": "0.30.0", | ||
@@ -25,0 +25,0 @@ "chai": "3.5.0", |
143
README.md
@@ -59,3 +59,3 @@ # PostCSS for Webpack [![Build Status][ci-img]][ci] | ||
var css = require('./file.css'); | ||
// => CSS after Autoprefixer and CSSWring | ||
// => CSS after PreCSS and Autoprefixer | ||
``` | ||
@@ -79,2 +79,17 @@ | ||
## Source Maps | ||
Loader will use source map settings from previous loader. | ||
You can set this `sourceMap` parameter to `inline` value to put source maps | ||
into CSS annotation comment: | ||
```js | ||
module.exports = { | ||
module: { | ||
loader: "style-loader!css-loader!postcss-loader?sourceMap=inline" | ||
} | ||
} | ||
``` | ||
## Plugins Packs | ||
@@ -108,4 +123,46 @@ | ||
## Integration with postcss-import | ||
## Custom Syntaxes | ||
PostCSS can transforms styles in any syntax, not only in CSS. | ||
There are 3 parameters to control syntax: | ||
* `syntax` accepts module name with `parse` and `stringify` function. | ||
* `parser` accepts module name with input parser function. | ||
* `stringifier` accepts module name with output stringifier function. | ||
For example, you can use [Safe Parser] to find and fix any CSS errors: | ||
```js | ||
var css = require('postcss?parser=postcss-safe-parser!./broken') | ||
``` | ||
[Safe Parser]: https://github.com/postcss/postcss-safe-parser | ||
If you need to pass the function directly instead of a module name, | ||
you can do so through the webpack postcss option, as such: | ||
```js | ||
var sugarss = require('sugarss') | ||
module.exports = { | ||
module: { | ||
loaders: [ | ||
{ | ||
test: /\.css$/, | ||
loader: "style-loader!css-loader!postcss-loader" | ||
} | ||
] | ||
}, | ||
postcss: function () { | ||
return { | ||
plugins: [autoprefixer, precss], | ||
syntax: sugarss | ||
}; | ||
} | ||
} | ||
``` | ||
## Examples | ||
### With postcss-import | ||
When using [postcss-import] plugin, you may want to tell webpack about | ||
@@ -142,3 +199,3 @@ dependencies coming from your `@import` directives. | ||
## Integration with CSS Modules | ||
### With CSS Modules | ||
@@ -162,42 +219,2 @@ `postcss-loader` [cannot be used] with [CSS Modules] out of the box due | ||
[CSS Modules]: https://github.com/webpack/css-loader#css-modules | ||
## JS Styles | ||
If you want to process styles written in JavaScript | ||
you can use the [postcss-js] parser. | ||
```js | ||
{ | ||
test: /\.style.js$/, | ||
loader: "style-loader!css-loader!postcss-loader?parser=postcss-js" | ||
} | ||
``` | ||
Or use can use even ES6 in JS styles by Babel: | ||
```js | ||
{ | ||
test: /\.style.js$/, | ||
loader: "style-loader!css-loader!postcss-loader?parser=postcss-js!babel" | ||
} | ||
``` | ||
As result you will be able to write styles as: | ||
```js | ||
import colors from '../config/colors'; | ||
export default { | ||
'.menu': { | ||
color: colors.main, | ||
height: 25, | ||
'&_link': { | ||
color: 'white' | ||
} | ||
} | ||
} | ||
``` | ||
[postcss-js]: https://github.com/postcss/postcss-js | ||
## Custom Syntaxes | ||
@@ -242,1 +259,41 @@ | ||
``` | ||
### JS Styles | ||
If you want to process styles written in JavaScript | ||
you can use the [postcss-js] parser. | ||
```js | ||
{ | ||
test: /\.style.js$/, | ||
loader: "style-loader!css-loader!postcss-loader?parser=postcss-js" | ||
} | ||
``` | ||
Or use can use even ES6 in JS styles by Babel: | ||
```js | ||
{ | ||
test: /\.style.js$/, | ||
loader: "style-loader!css-loader!postcss-loader?parser=postcss-js!babel" | ||
} | ||
``` | ||
As result you will be able to write styles as: | ||
```js | ||
import colors from '../config/colors'; | ||
export default { | ||
'.menu': { | ||
color: colors.main, | ||
height: 25, | ||
'&_link': { | ||
color: 'white' | ||
} | ||
} | ||
} | ||
``` | ||
[postcss-js]: https://github.com/postcss/postcss-js |
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
12939
294
Updatedloader-utils@^0.2.15
Updatedpostcss@^5.1.2