-
Notifications
You must be signed in to change notification settings - Fork 14
/
gulpfile.js
51 lines (48 loc) · 1.17 KB
/
gulpfile.js
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
51
var gulp = require('gulp');
var concat = require('gulp-concat');
var webpack = require('gulp-webpack');
var uglify = require('gulp-uglify');
var header = require('gulp-header');
var fs = require('fs');
var jsdoc = require('gulp-jsdoc');
var jshint = require('gulp-jshint');
var headerData = {
now: (function (dt) {
return dt.toLocaleDateString() + " " + dt.toLocaleTimeString();
})(new Date())
};
/**
* 代码检查
*/
gulp.task('checkCode', function () {
gulp.src('./modules/*.js')
.pipe(jshint())
.pipe(jshint.reporter('gulp-jshint-html-reporter', {
filename: './build/jshint-output.html',
createMissingFolders: false
}));
});
/**
* 打包压缩
*/
gulp.task('default', ['checkCode'], function () {
//文件头说明
var txt = fs.readFileSync('./modules/copyright.txt', 'utf8');
//开始处理
gulp.src('./modules/*.js')
.pipe(jsdoc('./doc/'))
.pipe(webpack({
entry: {
index: './modules/main.js'
},
resolve: {
root: './modules/'
}
})).pipe(concat('XJsTool.js'))
.pipe(header(txt, headerData))
.pipe(gulp.dest('build/'))
.pipe(concat('XJsTool.min.js'))
.pipe(uglify())
.pipe(header(txt, headerData))
.pipe(gulp.dest('build/'));
});