Benjamin Oats Benjamin Oats - 2 months ago 33
CSS Question

Grunt postcss task exclude files

I am trying to set up

postcss grunt task
, i am wanting to run the task on all files in css/ except default.css, how do i exclude certain files?

This is my task

options: {
processors: [
require('autoprefixer')(),
require('cssnext')(),
require('precss')()
]
},
dist: {
src: 'css/*.css',
exclude: 'css/default.css'

}

}

Answer

Somthing like:

    dist: {
        src: ['css/*.css', '!css/default.css']
    }

should do the trick.

Have a read of the docs on grunt.file.match

Match one or more globbing patterns against one or more file paths. Returns a uniqued array of all file paths that match any of the specified globbing patterns. Both the patterns and filepaths argument can be a single string or array of strings. Paths matching patterns that begin with ! will be excluded from the returned array. Patterns are processed in order, so inclusion and exclusion order is significant.