문제

I'm trying to concatenate all the JS libraries in our project into a single file. So I've set up a concat task in grunt, with the following file selector:

dist : {
  src  : ["public/lib/**/*.js"],
  dest : "public/lib.concat.js"
}

So far so good. However, we use sprintf.js in our project. So there is a sprintf.js directory inside of public/lib and that directory is matched by the src selector in grunt.

The result of that is:

$ grunt
Running "concat:dist" (concat) task
Warning: Unable to read "public/lib/sprintf.js" file (Error code: UNKNOWN). Use --force to continue.

I'm aware that I could simply pick a different name for the sprintf.js directory, but I would like to know if there is a way to tell grunt to only select actual files, not directories.

도움이 되었습니까?

해결책

Use filter option to ignore directories:

dist : {
  src  : ["public/lib/**/*.js"],
  dest : "public/lib.concat.js",
  filter: function(filepath) {
    return !grunt.file.isDir(filepath);
  }
}

다른 팁

it should be even easier. you can just exclude with an exclamation pointer:

dist : {
  src  : ["public/lib/**/*.js", "!public/lib/sprintf.js" ],
  dest : "public/lib.concat.js"
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top