Gulp exclude does not work as expected

2019-07-31 09:33发布

问题:

I have a gulp task that looks like this, just the src part:

gulp.src(
    [
    'site/bricks/global/global.scss',
    'site/bricks/**/*.scss',
    '!site/bricks/global/domain*.scss',
    'site/bricks/global/domain.mydomain.com.scss'
    ])

I expect it to do this:

  • Load global.scss first (works)
  • Load the rest of the scss files (works)
  • Exclude all but domain (works)
  • Include one of my domains back (does not work)

So for some reason I can't add a domain back to the list. Any ideas?

回答1:

It looks like that is expected behavior because all negation globs run last! See gulp.src negation order issues.

You have a few options though:

1.. Use gulp4.0 - supposed to be fixed there.

2.. gulp-add-src add that last file back in.

3.. merge2 create two separate streams and then merge them.



标签: gulp src