Grunt postcss 任务排除文件

Grunt postcss task exclude files

我正在尝试设置 postcss grunt task,我想要 运行 css/ 中所有文件的任务,除了 default.css,如何排除某些文件?

这是我的任务

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

        }

    }

签出 docs

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.

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

类似的东西:

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

应该可以解决问题。

阅读 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.