2016-07-14 7 views
0

gulpタスクを使用してプロダクションに展開していますが、gulp-deployに問題があります。サーバ上の別の場所にコピーする他のファイルが必要です。Gulpプロダクションにftpを導入

//Gulp APP ftp deploy 
gulp.task('deploy-app', function() { 

    var conn = ftp.create({ 
     host: 'xxx', 
     user: 'xxx', 
     password: 'xxx', 
     parallel: 10, 
     log: gutil.log 
    }); 

    var globs = [ 
     './css/**/*{css,png,jpg,gif,ttf,woff,eof,svg,woff2}', 
     './img/**', 
     './views/**', 
     './scripts/**', 
     'index.html', 
     'Web.config' 
    ]; 

    // using base = '.' will transfer everything to /public_html correctly 
    // turn off buffering in gulp.src for best performance 

    return gulp.src(globs, { base: '.', buffer: false }) 
     .pipe(conn.newer('/site/wwwroot')) // only upload newer files 
     .pipe(conn.dest('/site/wwwroot')); 

}); 

私がここに持っている問題は、私は、フォルダdistの内にある別ののindex.htmlを持っているので、私は、ルートからのindex.htmlを必要といけないということですが、それは、サーバーのフォルダのルートに行かなければなりません、行う方法

答えて

1

他のファイルのいずれかに影響を与えることなく、あなたのindex.htmlファイルの宛先ディレクトリのみを変更するgulp-renameと組み合わせてgulp-ifを使用します。

var gulpIf = require('gulp-if'); 
var rename = require('gulp-rename'); 

gulp.task('deploy-app', function() { 

    var conn = ftp.create({ 
     host: 'xxx', 
     user: 'xxx', 
     password: 'xxx', 
     parallel: 10, 
     log: gutil.log 
    }); 

    var globs = [ 
     './css/**/*{css,png,jpg,gif,ttf,woff,eof,svg,woff2}', 
     './img/**', 
     './views/**', 
     './scripts/**', 
     './dist/index.html', 
     'Web.config' 
    ]; 

    return gulp.src(globs, { base: '.', buffer: false }) 
     .pipe(gulpIf('dist/index.html', rename({dirname:''}))) 
     .pipe(conn.newer('/site/wwwroot')) 
     .pipe(conn.dest('/site/wwwroot')); 
}); 
関連する問題