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);
}
}