My gulp code looks like this, in part
gulp.src([\'../application-base/**/**.js\', \'!../application-base/assets/**/**.js\'], { base: \'./\' })
.pipe(gulpPlum
In gulp streams the destination path of a file follows this pseudo-equation:
gulp.dest
+ (gulp.src
without leading base
) = dest path of file
Example:
gulp.src('src/js/foo.js', {base:'src/'}).pipe(gulp.dest('dist/'));
Result:
'dist/'
+ ('src/js/foo.js'
without leading 'src/'
) = 'dist/js/foo.js'
In your case:
'../application-base-transpiled/'
+ ('../application-base/foo/bar.js'
without leading './'
) = '../application-base-transpiled/../application-base/foo/bar.js'
So your files end up in the original directory.
You have to pass {base: '../application-base/'}
to gulp.src()
to make your example work.
NOTE
You still need to include '../application-base/'
in your src
path. The purpose of base
is to manipulate the dest path, per my equation above; it does not serve the purpose of lessening the number of keystrokes you type in gulp.src
. So the end result should be something like this
gulp.src(['../application-base/**/**.js'], { base: '../application-base' })
.pipe(gulpPlumber({
errorHandler: function errorHandler(error) {
console.log('\nError ' + error);
this.emit('end');
}
}))
.pipe(gprint(filePath => "Transpiling: " + filePath.replace('..\\application-base\\', '')))
.pipe(babel({ compact: false }))
.pipe(gulp.dest('../application-base-transpiled'))
.on('end', () => done());
If you don't pass a base option to gulp.src()
a default is set:
Default: everything before a glob starts (see glob2base)
What this means is that everything up to the first **
or *
in the pattern that you pass to gulp.src()
is used as the base
option. Since your pattern is ../application-base/**/**.js
, your base
option automatically becomes ../application-base/
.