Looking for way to copy files in gulp and rename based on parent directory

前端 未结 5 1829
自闭症患者
自闭症患者 2020-12-02 06:51

For each module I have some files that need to be copied over to the build directory, and am looking for a way to minimize the repeated code from this:

gulp         


        
5条回答
  •  我在风中等你
    2020-12-02 07:27

    The best way is to configure your base when sourcing files, like so:

    gulp.src('./client/src/modules/**/index.js', {base: './client/src/modules'})
      .pipe(gulp.dest('./build/public/js/'));
    

    This tells gulp to use the modules directory as the starting point for determining relative paths.

    (Also, you can use /**/*.js if you want to include all JS files...)

提交回复
热议问题