Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-loader

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-loader - npm Package Compare versions

Comparing version 0.8.2 to 0.9.0

3

CHANGELOG.md

@@ -0,1 +1,4 @@

## 0.9
* Allow to pass syntax, parser or stringifier as function (by Jeff Escalante).
## 0.8.2

@@ -2,0 +5,0 @@ * Fix source map support (by Andrew Bradley).

35

index.js

@@ -22,19 +22,30 @@ var loaderUtils = require('loader-utils');

if ( params.syntax ) opts.syntax = require(params.syntax);
if ( params.parser ) opts.parser = require(params.parser);
if ( params.stringifier ) opts.stringifier = require(params.stringifier);
var plugins = this.options.postcss;
if ( typeof plugins === 'function' ) {
plugins = plugins.call(this, this);
var options = this.options.postcss;
if ( typeof options === 'function' ) {
options = options.call(this, this);
}
if ( typeof plugins === 'undefined' ) {
var plugins;
if ( typeof options === 'undefined' ) {
plugins = [];
} else if ( params.pack ) {
plugins = plugins[params.pack];
} else if ( !Array.isArray(plugins) ) {
plugins = plugins.defaults;
} else if ( !Array.isArray(options) ) {
plugins = options.plugins || options.defaults;
opts.stringifier = options.stringifier;
opts.parser = options.parser;
opts.syntax = options.syntax;
}
if ( params.pack ) {
plugins = options[params.pack];
}
if ( params.syntax ) {
opts.syntax = require(params.syntax);
}
if ( params.parser ) {
opts.parser = require(params.parser);
}
if ( params.stringifier ) {
opts.stringifier = require(params.stringifier);
}
var loader = this;

@@ -41,0 +52,0 @@ var callback = this.async();

{
"name": "postcss-loader",
"version": "0.8.2",
"version": "0.9.0",
"description": "PostCSS loader for webpack",

@@ -10,3 +10,3 @@ "keywords": ["webpack", "loader", "css", "postcss", "postcss-runner"],

"dependencies": {
"loader-utils": "^0.2.12",
"loader-utils": "^0.2.14",
"postcss": "^5.0.19"

@@ -17,3 +17,3 @@ },

"postcss-safe-parser": "1.0.7",
"webpack-stream": "3.1.0",
"webpack-stream": "3.2.0",
"gulp-eslint": "2.0.0",

@@ -24,3 +24,3 @@ "json-loader": "0.5.4",

"gulp-mocha": "2.2.0",
"fs-extra": "0.26.5",
"fs-extra": "0.30.0",
"chai": "3.5.0",

@@ -27,0 +27,0 @@ "gulp": "3.9.1"

@@ -21,7 +21,13 @@ # PostCSS for Webpack [![Build Status][ci-img]][ci]

Install `postcss-loader`:
```console
npm install postcss-loader --save-dev
```
Set `postcss` section in webpack config:
```js
var precss = require('precss');
var autoprefixer = require('autoprefixer');
var precss = require('precss');

@@ -38,3 +44,3 @@ module.exports = {

postcss: function () {
return [autoprefixer, precss];
return [precss, autoprefixer];
}

@@ -44,2 +50,9 @@ }

> This example implementation uses two plugins that may need to be installed:
>
> ```console
> npm install precss --save-dev
> npm install autoprefixer --save-dev
> ```
Now your CSS files requirements will be processed by selected PostCSS plugins:

@@ -71,3 +84,3 @@

If you want to process different styles by different PostCSS plugins you can
define plugin packs in `postcss` section and use them by `?pack=name` parameter.
define plugin packs in `postcss` section and use them by `?pack=name` parameter.

@@ -90,3 +103,3 @@ ```js

return {
defaults: [autoprefixer, precss],
defaults: [precss, autoprefixer],
cleaner: [autoprefixer({ browsers: [] })]

@@ -101,3 +114,3 @@ };

When using [postcss-import] plugin, you may want to tell webpack about
dependencies coming from your `@import` directives.
dependencies coming from your `@import` directives.
For example: in watch mode, to enable recompile on change.

@@ -145,3 +158,3 @@

or replace `css-loader` with [postcss-modules] plugin.
or use [postcss-modules] plugin instead of `css-loader`.

@@ -208,1 +221,24 @@ [`importLoaders` option]: https://github.com/webpack/css-loader#importing-and-chained-loaders

[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
};
}
}
```
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc