Package detail

@webpack-blocks/postcss

andywer2.9kMIT2.1.0

Webpack block for PostCSS.

webpack, webpack-blocks

readme

webpack-blocks - PostCSS

Gitter chat NPM Version

This is the postcss block providing PostCSS configuration.

Usage

const { createConfig, match } = require('@webpack-blocks/webpack')
const { css } = require('@webpack-blocks/assets')
const postcss = require('@webpack-blocks/postcss')

module.exports = createConfig([
  match(['*.css', '!*node_modules*'], [
    css(),
    postcss()
  ])
])

NOTE: the postcss block handles only the postcss transformation, you must use the css block if you want to require the css in your browser.

We recommend you to configure PostCSS using the postcss.config.js file (see PostCSS loader usage):

// postcss.config.js
const autoprefixer = require('autoprefixer')

module.exports = {
  plugins: [autoprefixer({ browsers: ['last 2 versions'] })]
}

But you can pass configuration directly to the postcss block:

const { createConfig, match } = require('@webpack-blocks/webpack')
const { css } = require('@webpack-blocks/assets')
const postcss = require('@webpack-blocks/postcss')
const autoprefixer = require('autoprefixer')

module.exports = createConfig([
  css(),
  postcss({
    plugins: [autoprefixer({ browsers: ['last 2 versions'] })]
    /* Other PostCSS options */
  })
])

Options

PostCSS options

parser (optional)

Package name of a custom PostCSS parser to use. Pass for instance 'sugarss' to be able to write indent-based CSS.

stringifier (optional)

Package name of a custom PostCSS stringifier to use.

syntax (optional)

Package name of a custom PostCSS syntax to use. The package must export a parse and a stringify function.

plugins (optional)

Array of PostCSS plugins.

webpack-blocks

Check out the

👉 Main documentation

Released under the terms of the MIT license.

changelog

@webpack-blocks/postcss - Changelog

2.0.0-alpha.1

2.0.0-alpha

  • Support for webpack 4 (#261)

1.0.0-rc

  • Breaking change: Remove plugins argument
  • Add minimize option

1.0.0-beta

  • Use match() instead of exclude/include option

1.0.0-alpha

  • Updated for new core API (#125)
  • Requires node 6+

0.4.3

  • Bug fix: Fix loading of postcss.config.js (#137)

0.4.2

  • Bug fix: Fix postcss/sass crash when using webpack 2 and source maps (#116)

0.4.1

  • Made plugins parameter optional (#112)

0.4.0

  • Breaking change: Dropped the default node_modules/ exclusion

0.3.2

  • Bug fix: PostCSS plugin configuration now works with webpack 2 (#68)

0.3.1

  • Supporting custom PostCSS options now (parser, stringifier, syntax)

0.3.0

  • Adapted to new API: Using context now

0.2.0

  • Fix loader order issue
  • Upgraded to postcss-loader v1.2.0 which supports reading the postcss.config.js file

0.1.1

  • loaders: [ 'postcss' ] => loaders: [ 'postcss-loader' ]

0.1.0

Initial release.