-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
101 lines (101 loc) · 2.78 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"use strict";
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')(),
del = require('del');
//路径
var releasePath = 'gh-pages/release/',
releaseSrc = 'dist/*.{css,js}',
resDest = 'dist/',
resSrc = 'src/',
jsSrc = 'src/paging.js',
jsMinName = 'paging.min.js',
scssSrc = 'src/paging.scss',
cssSrc = 'src/paging.css',
cssMinName = 'paging.min.css';
gulp.task('jshint', function() {
return gulp.src(jsSrc)
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('default'));
});
gulp.task('js',function () {
return gulp.src(jsSrc)
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('default'))
.pipe(gulp.dest(resDest))
.pipe(plugins.rename(jsMinName))
.pipe(plugins.uglify())
.pipe(gulp.dest(resDest));
});
gulp.task('scss',function () {
return gulp.src(scssSrc)
.pipe(plugins.scssLint({
'config': 'scsslint.yml'
}))
.pipe(plugins.sourcemaps.init())
.pipe(plugins.sass({outputStyle:'expanded'}).on('error', plugins.sass.logError))
.pipe(plugins.sourcemaps.write())
.pipe(plugins.autoprefixer({
browsers:[
'Android 2.3',
'Android >= 4',
'Chrome >= 20',
'Firefox >= 24',
'Explorer >= 8',
'iOS >= 6',
'Opera >= 12',
'Safari >= 6'
],
cascade: true,
remove:true
}))
.pipe(gulp.dest(resSrc));
});
gulp.task('testscss',function () {
return gulp.src('src/paging.scss')
.pipe(plugins.scssLint())
.pipe(plugins.scssLint.failReporter());
});
gulp.task('css',['scss'],function () {
return gulp.src(cssSrc)
.pipe(gulp.dest(resDest))
.pipe(plugins.cleanCss({
advanced: false,
compatibility: 'ie8',
keepSpecialComments: '*',
format:{
breaks: {
afterRuleEnds: true
}
}
}))
.pipe(plugins.rename(cssMinName))
.pipe(gulp.dest(resDest));
});
gulp.task('dev', function() {
gulp.watch(scssSrc,['scss']);
gulp.watch(jsSrc,['jshint']);
});
gulp.task('deploy-html',function () {
return gulp.src('demo/*.html')
.pipe(plugins.replace(/\.\.\/src/g,'./src'))
.pipe(plugins.replace(/\.\.\/resource/g,'./resource'))
.pipe(gulp.dest('gh-pages/'));
});
gulp.task('deploy-res',function () {
return gulp.src('dist/*')
.pipe(gulp.dest('gh-pages/src/'));
});
gulp.task('deploy-resource',function () {
return gulp.src('resource/*')
.pipe(gulp.dest('gh-pages/resource/'));
});
gulp.task('release',['css','js'],function() {
return gulp.src(releaseSrc)
.pipe(plugins.zip('paging.zip'))
.pipe(gulp.dest(releasePath));
});
gulp.task('build',['css','js','release']);
gulp.task('deploy',['deploy-html','deploy-res','deploy-resource'],function () {
return gulp.src('./gh-pages/**/*')
.pipe(plugins.ghPages());
});