Maintain Directory Structure while Globbing

If you are planning to read a few files/folders from a directory and maintain their relative path, you need to pass {base: '.'} as the second argument to gulp.src().

For example, if you have a directory structure like

Dev setup

and want to read only a few files say

[ 'index.html',
 'css/**',
 'js/**',
 'lib/**',
 'images/**',
 'plugin/**'
 ]

In this case, Gulp will read all the sub-folders of (say) css folder and arrange them relative to your root folder and they will no longer be the sub-folder of css. The output after globbing would look like

Zipped-Unzipped

If you want to maintain the structure, you need to pass {base: '.'} to gulp.src(). Like

gulp.task('task', function () {
   gulp.src(['index.html', 
             'css/**', 
             'js/**', 
             'lib/**', 
             'images/**', 
             'plugin/**'
             ], {base: '.'})
       .pipe(operation1())
       .pipe(operation2());
});

And the input to your operation1() will be a folder structure like

with-base

results matching ""

    No results matching ""