Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by yan on 16-10-28.
- */
- var gulp = require('gulp');
- var sftp = require('gulp-sftp');
- var paths = require('./paths');
- var browserSync = require('browser-sync');
- var $ = require('gulp-load-plugins')();
- var config = {
- remoteInitPath: '/usr/share/nginx/html/cornerstone_ui',//后面不要跟'/'
- host: '192.168.110.185',
- user: 'root',
- pass: '××××××'
- }
- /**
- * 远程自动复制替换文件
- */
- gulp.task('remote-upload', function () {
- gulp.watch('assets/**/*', function (event) {
- var msg = [
- $.util.colors.magenta(event.path),
- 'was',
- $.util.colors.cyan(event.type)
- ];
- $.util.log(msg.join(' '));
- return gulp.src(event.path)
- .pipe(sftp({
- host: config.host,
- user: config.user,
- pass: config.pass,
- remotePath: calDestPath(event.path)
- }));
- });
- });
- function calDestPath(src) {
- var from = src.indexOf('assets/') + 6;
- var end = src.lastIndexOf('/');
- return config.remoteInitPath + src.substring(from, end);
- }
- gulp.task('browser-sync', function () {
- browserSync.init({
- proxy: "127.0.0.1:3000",
- port: 8083,
- logLevel: 'debug',
- ui: {
- port: 8089
- }
- });
- gulp.watch('www/**/*').on("change", function () {
- browserSync.reload();
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement