Gulp移动没有目录结构的文件[重复]

时间:2022-09-01 21:04:39

This question already has an answer here:

这个问题在这里已有答案:

How do I move files using Gulp from different folders in my src directory into the dist folder without keeping the directory structure from src.

如何使用Gulp将文件从我的src目录中的不同文件夹移动到dist文件夹中,而不保留src中的目录结构。

For eg:

var sourceFiles = [
  "src/folder1/test.js",
  "src/folder1/test1.js"
];

should be moved to the dist folder i.e:

应该移到dist文件夹,即:

dist/test.js
dist/test1.js

Using something like this:

使用这样的东西:

gulp.task("moveFiles",function(){
    return gulp.src(sourceFiles, {base: "src"})
      .pipe(gulp.dest("dist"));
});

moves it to dist/folder1 ie

将它移动到dist / folder1即

dist/folder1/test.js
dist/folder1/test1.js

1 个解决方案

#1


0  

I ended up solving the issue without using the base option:

我最终解决了这个问题而没有使用基本选项:

gulp.task("moveFiles",function(){
    return gulp.src(sourceFiles)
      .pipe(gulp.dest("dist"));
});

#1


0  

I ended up solving the issue without using the base option:

我最终解决了这个问题而没有使用基本选项:

gulp.task("moveFiles",function(){
    return gulp.src(sourceFiles)
      .pipe(gulp.dest("dist"));
});