gtg092x / gulp-sftp

Gulp SFTP Deploy
140 stars 61 forks source link

Question: How do I only SFTP files which have changed after minification? #6

Closed u01jmg3 closed 10 years ago

u01jmg3 commented 10 years ago

Can't seem to only upload the file that has changed after CSS minification.

e.g.

var gulp = require('gulp'),
    changed = require('gulp-changed'),
    minifycss = require('gulp-minify-css'),
    sftp = require('gulp-sftp')
;

var src = './src/',
    dist = './dist/';

var srcStyles = src + '**/*.css',
    distStyles = dist + '**/*.css';

var host = 'ftp.xxxx.xx.xx',
    auth = 'keyMain',
    remotePath = 'public_html';

gulp.task('compilecss', function(){
    gulp.src(srcStyles)
        .pipe(changed(dist))
        .pipe(minifycss({keepBreaks: true}))
        .pipe(gulp.dest(dist))
    ;
});

gulp.task('uploadcss', function(){
    gulp.src(distStyles)
        .pipe(changed(dist))
        .pipe(sftp({
            host: host,
            auth: auth,
            remotePath: remotePath
        }))
    ;
});

gulp.task('main', function(){
    gulp.start('compilecss');
});

gulp.task('watch', function(){
    gulp.watch(srcStyles, ['compilecss']);
    gulp.watch(distStyles, ['uploadcss']);
});

gulp.task('default', ['main', 'watch']);
gtg092x commented 10 years ago

I'll have to try and recreate. Though I'm just using the steam as I get it.

Sent with AquaMail for Android http://www.aqua-mail.com

On May 8, 2014 1:59:29 PM Jonathan Goode notifications@github.com wrote:

Can't seem to only upload files that have changed after minification.

e.g.

var gulp = require('gulp');

var plumber = require('gulp-plumber'),
    changed = require('gulp-changed'),
    minifycss = require('gulp-minify-css'),
    sftp = require('gulp-sftp'),
    gutil = require('gulp-util')
;

var src = './src/',
    dist = './dist/';

var srcStyles = src + '**/*.css';
var distStyles = dist + '**/*.css';

var host = 'ftp.xxxx.xx.xx',
    auth = 'keyMain',
    remotePath = 'public_html';

/*------------------------------------------------*/

var onError = function(error){
    gutil.beep();
    console.log(error);
};

/*------------------------------------------------*/

gulp.task('compilecssremote', function(){
    gulp.src(srcStyles)
        .pipe(plumber({
            errorHandler: onError
        }))
        .pipe(changed(dist)) //must be dist
        .pipe(minifycss({keepBreaks: true}))
        .pipe(gulp.dest(dist))
    ;
});

gulp.task('uploadcss', function(){
    gulp.src(distStyles)
        .pipe(plumber({
            errorHandler: onError
        }))
        .pipe(changed(dist))
        .pipe(sftp({
            host: host,
            auth: auth,
            remotePath: remotePath
        }))
    ;
});

gulp.task('mainremote', function(){
    gulp.start('compilecssremote');
});

gulp.task('watchremote', function(){
    gulp.watch(srcStyles, ['compilecssremote']);
    gulp.watch(distStyles, ['uploadcss']);
});

/*------------------------------------------------*/

gulp.task('default', ['mainremote', 'watchremote']);

Reply to this email directly or view it on GitHub: https://github.com/gtg092x/gulp-sftp/issues/6

u01jmg3 commented 10 years ago

Let me know if you need me to test/clarify anything. Thanks

u01jmg3 commented 10 years ago

Managed to fix this: https://github.com/gulpjs/gulp/issues/465#issuecomment-43213352