gulpfile.js 1.06 KB
var gulp = require('gulp');
var gutil = require('gulp-util');
var ftp = require('gulp-ftp');
var fs = require('fs');
var exec = require('child_process').exec;
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');

var ftpConfig = {
    host: '218.94.75.58',
    user: 'php',
    pass: 'yoho9646'
};

gulp.task('default', function() {

});

//js代码验证
gulp.task('lint', function() {
    return gulp.src(['src/*.js', 'src/**/*.js'])
        .pipe(jshint())
        .pipe(jshint.reporter(stylish));
});


//发布到CDN
gulp.task('dist', ['build'], function() {
    var ftpstream = ftp(ftpConfig);
    return gulp.src('dist/**')
        .pipe(ftpstream)
        .pipe(gutil.noop());
});

gulp.task('build', function(done) {
    webpack(webpackConfig, function(err, stats) {
        if (err) {
            throw new gutil.PluginError('webpack', err);
        }
        gutil.log('[webpack compile]:', stats.endTime - stats.startTime, 'ms');
        done();
    });
});