Search code examples
gulp

Error: Invalid glob argument for an src path, works as variable


Trying to set up gulp to concat some CSS files.

In my gulpfile.js I have this:

const paths = {
  css: {
    cssForConcat: [
      './css/*.css',
      '!./css/style.css',
    ],
  }
}

But this code:

function styles () {
  return gulp.src([paths.css.cssForConcat])

Returns an error:

[07:23:27] 'styles' errored after 811 μs
[07:23:27] Error: Invalid glob argument: ./css/*.css,!./css/style.css

Copying-and-pasting the constant value works OK with no error:

function styles () {
  return gulp.src('./css/*.css', '!./css/style.css')

What is wrong with my constant definition?


Solution

  • The problem is that you passed in [['./css/*.css', '!./css/style.css']] rather than './css/*.css', '!./css/style.css', just remove the brackets around paths.css.cssForConcat and it should work as expected.

    E.g.: return gulp.src(paths.css.cssForConcat)