Why isn't gulp filter filtering fewer files in my bower packages
I am trying to get all files in my bower components using the main bower files and filtering them by type using gulp-filter . it works great when i filter js files like this:
gulp.task('bower_js', function() {
var jsFilter = gulpFilter('**/*.js');
gulp.src(mainBowerFiles(), {base: './bower_components'})
.pipe(jsFilter)
.pipe(concat('vendor.js'))
.pipe(gulp.dest('./_public/js'));
});
however doing a similar task for a smaller amount doesn't work (i.e. nothing goes through the filter):
gulp.task('bower_css', function() {
var lessFilter = gulpFilter('**/*.less');
gulp.src(mainBowerFiles(), {base: './bower_components'})
.pipe(lessFilter)
// .pipe(less()) commented to narrow down the problem
.pipe(concat('app.css'))
.pipe(gulp.dest('./_public/css'));
});
although if I run mainBowerFiles without filter, it dumps the contents of the .less
files to the destination folder.
to give a concrete example .. this is the relevant part of bower.json
one of my bower: bootstrap packages:
"main": [
"less/bootstrap.less",
"dist/css/bootstrap.css",
"dist/js/bootstrap.js",
"dist/fonts/glyphicons-halflings-regular.eot",
"dist/fonts/glyphicons-halflings-regular.svg",
"dist/fonts/glyphicons-halflings-regular.ttf",
"dist/fonts/glyphicons-halflings-regular.woff"
],
bootstrap.less
in turn imports other files:
// Core variables and mixins
@import "variables.less";
@import "mixins.less";
// Reset and dependencies
@import "normalize.less";
@import "print.less";
..
etc.
any ideas?
source to share
I've tried to get something similar to SASS working with no luck. That is, until I discovered that there is now a built-in filter in the main-bower files . This is a regular expression. Try something like this instead of using gulp-filter:
gulp.task('bower_css', function() {
var lessRegEx = (/.*\.less$/i);
gulp.src(mainBowerFiles({filter: lessRegEx}), {base: './bower_components'})
// .pipe(less()) commented to narrow down the problem
.pipe(concat('app.css'))
.pipe(gulp.dest('./_public/css'));
});
source to share
Experienced fonts folder issue, strange combo for main-bower files (2.11.0) and gulp-filter (v3.0.1). Issue # 53 in gulp-filter looks similar, seams solution is basedir option.
main-bower-files + gulp-filter = doesn't work
gulp.src(mainBowerFiles())
.pipe(gulpFilter('**/fonts/*'))
.pipe(gulp.dest('./demo/assets/fonts'));
main-bower-files + basedir + gulp -filter = working
gulp.src(mainBowerFiles(), {base: './'})
.pipe(gulpFilter('**/fonts/*'))
.pipe(gulp.dest('./demo/assets/fonts'));
main-bower files with filter = worker
gulp.src(mainBowerFiles('**/fonts/*'))
.pipe(gulp.dest('./demo/assets/fonts'));
simple gulp.src + gulp -filter = working
gulp.src('bower_components/**')
.pipe(gulpFilter('**/fonts/*'))
.pipe(gulp.dest('./demo/assets/fonts'));
source to share