Created
May 7, 2016 20:00
-
-
Save arysom/9ab1bfd670d0be1e8899ac45ea6b432f to your computer and use it in GitHub Desktop.
Gulp upload through ftp after watch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var gulp = require('gulp'), | |
| watch = require('gulp-watch'), | |
| gutil = require( 'gulp-util' ), | |
| sass = require('gulp-sass'), | |
| notify = require("gulp-notify"), | |
| ftp = require( 'vinyl-ftp' ); | |
| gulp.task( 'deploy', ['css'], function () { | |
| var conn = ftp.create( { | |
| host: 'myhost', | |
| user: 'user@host', | |
| password: '****', | |
| parallel: 10, | |
| log: gutil.log | |
| } ); | |
| var globs = [ | |
| 'src/**', | |
| 'css/**', | |
| 'build/**', | |
| 'js/**', | |
| 'fonts/**', | |
| 'index.html' | |
| ]; | |
| // 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( '/test' ) ) // only upload newer files | |
| .pipe( conn.dest( '/test' ) ) | |
| .pipe(notify("Files have been send")) | |
| ; | |
| } ); | |
| gulp.task('css', function () { | |
| return gulp.src('scss/**/*.scss') | |
| .pipe(sass().on('error', sass.logError)) | |
| .pipe(gulp.dest('css')) | |
| }); | |
| gulp.task('watch', function (){ | |
| gulp.watch('scss/**/*.scss', ['css', 'deploy']); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment