[英]How to deploy gulp-ftp, after previos task?
i have a problem with two gulp task in npm.js. 我在npm.js中有两个吞咽任务有问题。 First task compile project, next tast deploy it on ftp.
第一个任务是编译项目,下一个尝试是将其部署在ftp上。 If I run them separately - all work, but when i try to use them together, its now work.
如果我分别运行它们-全部工作,但是当我尝试一起使用它们时,它现在可以工作。 I think its a stream error.
我认为这是流错误。 Cuz gulp ftp (second task) finish faster then (first task).
Cuz gulp ftp(第二个任务)完成得比第一个任务快。 Can someone help with this?
有人可以帮忙吗?
First task: 第一项任务:
gulp.task('build', ['nib', 'html', 'scripts'], function() {
var removeDist = del.sync('app/dist');
var buildCSS = gulp
.src('app/chache/css/*.css')
.pipe(cssnano())
.pipe(gulp.dest('app/dist/css'));
var buildImg = gulp
.src(['app/html-dev/img/**/*', '!app/html-dev/img/empty.jpg'])
.pipe(imagemin({
interlaced: true,
progressive: true,
svgoPlugins: [{ removeViewBox: false }],
une: [pngquant()]
}))
.pipe(gulp.dest('app/dist/img'));
var buildFonts = gulp
.src(["app/html-dev/fonts/**/*", '!app/html-dev/fonts/empty.woff'])
.pipe(gulp.dest('app/dist/fonts'));
var buildJS = gulp
.src("app/chache/js/**/*")
.pipe(gulp.dest('app/dist/js'));
var buildHhtml = gulp
.src("app/chache/*.html")
.pipe(gulp.dest('app/dist'));
});
Ftp Task: Ftp任务:
gulp.task('ftp', ['build'], function () {
return gulp.src('app/dist/**')
.pipe(ftp(ftpinfo))
// you need to have some kind of stream after gulp-ftp to make sure it's flushed
// this can be a gulp plugin, gulp.dest, or any kind of stream
// here we use a passthrough stream
.pipe(gutil.noop());
});
Error: 错误:
[13:34:47] Using gulpfile ~\Desktop\test-dist\gulpfile.js
[13:34:47] Starting 'nib'...
[13:34:47] Starting 'html'...
[13:34:47] Starting 'scripts'...
[13:34:47] Finished 'scripts' after 9.31 ms
[13:34:50] Finished 'nib' after 3.35 s
[13:34:50] Finished 'html' after 3.34 s
[13:34:50] Starting 'build'...
[13:34:50] Finished 'build' after 21 ms
[13:34:50] Starting 'ftp'...
[13:34:50] gulp-ftp: No files uploaded
[13:34:50] Finished 'ftp' after 6.5 ms
[13:34:50] gulp-imagemin: Minified 0 images
You need to return
the stream from the dependancy task, 'build'
. 您需要从依赖任务
'build'
return
流。 Otherwise the parent task 'ftp'
won't wait for 'build'
to end. 否则,父任务
'ftp'
将不会等待'build'
结束。
Since that task has multiple src
you need to merge them with merge-stream
由于该任务具有多个
src
您需要将它们与merge-stream
var merge = require('merge-stream');
gulp.task('build', ['nib', 'html', 'scripts'], function() {
var removeDist = del.sync('app/dist');
return merge(
gulp
.src('app/chache/css/*.css')
.pipe(cssnano())
.pipe(gulp.dest('app/dist/css')),
gulp
.src(['app/html-dev/img/**/*', '!app/html-dev/img/empty.jpg'])
.pipe(imagemin({
interlaced: true,
progressive: true,
svgoPlugins: [{ removeViewBox: false }],
une: [pngquant()]
}))
.pipe(gulp.dest('app/dist/img')),
gulp
.src(["app/html-dev/fonts/**/*", '!app/html-dev/fonts/empty.woff'])
.pipe(gulp.dest('app/dist/fonts')),
gulp
.src("app/chache/js/**/*")
.pipe(gulp.dest('app/dist/js')),
gulp
.src("app/chache/*.html")
.pipe(gulp.dest('app/dist'))
);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.