vigetlabs / blendid

A delicious blend of gulp tasks combined into a configurable asset pipeline and static site builder
MIT License
4.97k stars 685 forks source link

use PostCSS to process stylesheets #577

Closed olets closed 5 years ago

olets commented 5 years ago

Migrates Blendid to PostCSS. To test, add olets/blendid#postcss as a project dependency, and confirm that stylesheets are processed correctly. Tested with CSS (source files .css, stylesheets.sass false) and Sass (source files .scss, stylesheets true), and custom PostCSS config as below)

Users can configure plugins and options in task-config.js's stylesheets.postcss. See gulp-postcss for more info.

To support Sass with default options, set stylesheets to true (the default). To not include Sass processing, set stylesheets.sass to false.

Basic usage is unchanged:

// in task-config.js
stylesheets: true

If the custom PostCSS configuration does not include cssnano, it will be added dynamically. Same for Autoprefixer. This matches the current Blendid behavior where stylesheets are run through cssnano and Autoprefixer. (Custom cssnano and Autoprefixer configurations in task-config will be respected.)

A task-config with custom PostCSS will look like this (in this example, autoprefixer, some-other-plugin, and some-option must also be added as project dependencies)

// task-config.js

var autoprefixer    = require('autoprefixer')
var someOtherPlugin = require('some-other-plugin')
var someOption      = require('some-option')

var postCssPlugins = [
    autoprefixer({
        grid: "autoplace"
    }),
    someOtherPlugin()
]
var postCssOptions = {someOption}

module.exports = {
    // ...
    stylesheets: {
        // sass: true is implied
        postcss: {
           plugins: postCssPlugins,
           options: postCssOptions
        }
    }
    // ...
}

cc @solomonhawk — any further suggestions would be very welcome!

olets commented 5 years ago

Ah hm. Travis fails. Not clear to me why

olets commented 5 years ago

Found a bug, closing temporarily