gulpfile.js
1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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();
});
});