-
-
Save joeLepper/8393135 to your computer and use it in GitHub Desktop.
gulp.task('jade', function(){ | |
gulp.src(['src/js/directives/**/jade/*.jade', 'src/jade/views/*.jade']) | |
.pipe(jade({ pretty : true })) | |
.pipe(rename(function(dir,base,ext){ | |
var result = base + ext; | |
return result; | |
})) | |
.pipe(gulp.dest('./src/html')); | |
}); |
As for pathing:
By default gulp will use the relative path of base vs. cwd to figure out the output filename
If your CWD is ~/project
and your glob is src/js/directives/**/jade/*.jade
then this full path ~/project/src/js/directives/folder/jade/test.jade
will have a base of ~/project/src/js/directives/
and a relative path of folder/jade/test.jade
To flatten the path you need to modify the base of the file (which by default is where the glob starts)
file.base = path.dirname(file.path)
if you want to remove all folder structure and just put out flat files
This would be a good use case for a plugin if there isn't one already
Yeah. The syntax error is an oversight on my part. I'm actually storing all of these paths in variables in one location so that I can pass them in a way that makes sense to me. When I threw the gist together I forgot to copy the brackets, because computers are hard.
I've amended the gist to reflect this.
I'll start looking at how to spit out flat file tomorrow.
Dear future humans, use this to solve your problem: https://npmjs.org/package/gulp-flatten
@joeLepper gulp.src takes one glob or an array of globs. The way you are doing .src wouldn't include both globs. You should be doing