使用基本目录时,Gulp不会复制文件
这是最初的目录结构:
./src ./src/test.html ./gulpfile.js
目标只是将“src / test.html”复制到“build / index.html”。 我正在使用base base
选项来维护相对于build/
dir中的src/
的目录结构。
这里是gulpfile.js
var gulp = require('gulp'); var replace = require('gulp-replace'); gulp.task('default', function() { return gulp.src(['test.html'], {base: './src'}) .pipe(gulp.dest('build')); });
当我跑步时,我没有任何错误。 $ gulp [15:26:24]使用gulpfile /tmp/testproject/gulpfile.js [15:26:24]启动'default'… [15:26:24] 8.02 ms后完成'default'
但是,它并没有创buildbuild
目录:
$ find . . ./src ./src/test.html ./gulpfile.js
艾米我在这里错过了什么?
gulp.src正在searchgulpfile.js文件夹中的文件。 你应该改变你的任务:
gulp.task('default', function() { return gulp.src(['src/test.html'], {base: 'src'}) .pipe(gulp.dest('build')); });
gulp.src使用base参数来计算要放入输出stream的相对path,而不是设置读取文件的“当前”文件夹。