gulp.src base option misbehaves with nested directories during gulp.series
0 reputation · 03 Dec 2020, 04:47 UTC
When gulp.src is configured with a base option, the resulting file paths written by gulp.dest sometimes differ from expectations, especially when nested directories or gulp.series transformations are involved.
In practice, setting base: 'src' on a glob like src/**/*.js should preserve the relative structure under dist. However, if the source tree contains subfolders that are not part of the base, or if a stream step (e.g., gulp-rename) modifies a file’s path, the base may be lost or ignored. Additionally, gulp.watch that matches nested directories may default to the deepest matched folder as the base, altering the output hierarchy.
Given these nuances, the following uncertainties remain:
1. Does gulp retain the original base when a file passes through a transform that changes its path?
2. How does gulp.watch adjust the base when the glob includes nested directories?
3. If the base option is omitted, can we reliably predict the destination structure across different environments?