简体   繁体   中英

How to copy public folder from src to dist folder

I try to copy the public folder with gulp to the dist folder but it doesnt copy the structure right , any idea what am I doing wrong here ?

gulp.task('copy', () => {
    return gulp
        .src(['./src/config.json', './src/**/*.jade','./src/public/**/*'])
        .pipe(gulp.dest('dist'));
});

This is the public structure

在此输入图像描述

it copy all the folder inside the public folder under the root of dist without the public folder , how can I copy it as is (public and all sub files and folders as is)

This should copy all the files & folders within src :

gulp.task('copy', () => {
  return gulp
    .src('src/**/*')
    .pipe(gulp.dest('path/to/dist/from/gulpfile'));
});

Make sure the gulpfile is located at the same level as src . And the path to dest should be relative from the gulpfile.

You should copy public files in different task and set base directory in gulp.src:

gulp.task('copy_public', () => {
    return gulp
        .src(['./src/public/**/*'], {base: "./src/public"})
        .pipe(gulp.dest('dist'));
});

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