gulpfile.js
969 Bytes
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
46
47
48
49
50
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');
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));
});
//执行spm的build
gulp.task('spm', function(cb) {
exec('spm build --include standalone', function(err) {
if (err) return cb(err);
cb();
});
});
gulp.task('js', ['spm'], function() {
console.log("压缩合并完成");
});
//发布到CDN
gulp.task('dist', ['spm'], function() {
var ftpstream = ftp(ftpConfig);
return gulp.src('dist/**')
.pipe(ftpstream)
.pipe(gutil.noop());
});