reduce-css-postcss

1.0.3 • Public • Published

reduce-postcss

Plugin for reduce-css to pack postcss modules.

npm

version status coverage dependencies devDependencies

Example

See files in the example directory.

var gulp = require('gulp')
var del = require('del')
var reduce = require('reduce-css')
var postcss = require('reduce-css-postcss')
var path = require('path')
var fixtures = path.resolve.bind(path)

gulp.task('clean', function () {
  return del('build')
})

gulp.task('single-bundle', ['clean'], function () {
  return reduce
    .on('error', console.log.bind(console))
    .on('log', console.log.bind(console))
    .on('instance', function (b) {
      b.plugin(postcss)
    })
    .src('*.css', {
      basedir: fixtures('src'),
      factor: 'common.css',
    })
    .pipe(reduce.dest('build', null, {
      maxSize: 0,
      assetOutFolder: fixtures('build', 'images'),
    }))
})

gulp.task('watch-single-bundle', ['clean'], function () {
  reduce.watch()
    .on('error', console.log.bind(console))
    .on('log', console.log.bind(console))
    .on('instance', function (b) {
      b.plugin(postcss)
    })
    .src('*.css', {
      basedir: fixtures('src'),
      factor: 'common.css',
    })
    .pipe(reduce.dest, 'build', null, {
      maxSize: 0,
      assetOutFolder: fixtures('build', 'images'),
    })
})

gulp.task('multiple-bundles', ['clean'], function () {
  return reduce
    .on('error', console.log.bind(console))
    .on('log', console.log.bind(console))
    .on('instance', function (b) {
      b.plugin(postcss)
    })
    .src('*.css', {
      basedir: fixtures('src'),
      factor: {
        needFactor: true,
        common: 'common.css',
      },
    })
    .pipe(reduce.dest('build', null, {
      maxSize: 0,
      useHash: true,
      assetOutFolder: fixtures('build', 'images'),
    }))
})

gulp.task('watch-multiple-bundles', ['clean'], function () {
  reduce.watch()
    .on('error', console.log.bind(console))
    .on('log', console.log.bind(console))
    .on('instance', function (b) {
      b.plugin(postcss)
    })
    .src('*.css', {
      basedir: fixtures('src'),
      factor: {
        needFactor: true,
        common: 'common.css',
      },
    })
    .pipe(reduce.dest, 'build', null, {
      maxSize: 0,
      useHash: true,
      assetOutFolder: fixtures('build', 'images'),
    })
})

options

processorFilter

Type: Function

Receive a pipeline instance, through which you can add, remove, or customize postcss plugins to apply.

Type: Array

Specify extra postcss plugins to apply.

Default plugins

Readme

Keywords

Package Sidebar

Install

npm i reduce-css-postcss@1.0.3

Version

1.0.3

License

MIT

Last publish

Collaborators

  • zoubin