简体   繁体   中英

Gulp exclude all files and folder

I am trying to exclude a task from watching or moving a set of files.

Basically I want to move all the files I set up using the variable all_web_files:

gulp.task('move-files', function()
  {
    gutil.log( gutil.colors.bgCyan.bold('Moving Folders to Build'));

    //Move the web files
    gulp.src(all_web_files)
      .pipe(gulp.dest(build));

});

then:

var     all_web_files = [ 
                        site + '**/*', '!web_server/resources/{assets,assets/**}',
                        ch_core + '**/*',
                        ch_server + '**/*', 
                        ch_server + '!{p4p_api,p4p_api/**}',
                        ch_server + '!{p4p_ebextensions,p4p_ebextensions/**}'
                    ];

So basically I want to exclude the assets folder and everything in it as well as the folders p4p_api and p4p_ebextensions and everything in them. Unfortunately those folders keep getting moved over. I suspect I am not excluding them right.

You put your exclamation mark in the wrong place. Try it that way:

var all_web_files = [ 
                        ch_core + '**/*',
                        ch_server + '**/*', 
                        '!' + site + '**/*', 'web_server/resources/{assets,assets/**}',                          
                        '!' + ch_server + '{p4p_api,p4p_api/**}',
                        '!' + ch_server + '{p4p_ebextensions,p4p_ebextensions/**}'
                    ];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM