-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
100 lines (85 loc) · 4.33 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
var gulp = require('gulp'),
concat = require('gulp-concat'),
sourcemaps = require('gulp-sourcemaps'),
sass = require('gulp-sass'),
uglify = require('gulp-uglify'),
cssmin = require('gulp-minify-css'),
cleanCSS = require('gulp-clean-css'),
connect = require('gulp-connect'),
runSequence = require('run-sequence'),
rev = require('gulp-rev'),
revCollector = require('gulp-rev-collector');
gulp.task('uglifyJS', function() {
gulp.src(['./src/demo/jquery-1.12.4.min.js','./src/demo/prettify.min.js', './src/lib/reasy-ui.js', './src/lib/BaseComponent.js', './src/lib/FormInput.js', './src/lib/FormCheckbox.js', './src/lib/FormCheckList.js', './src/lib/FormRadioList.js', './src/lib/FormDropDownList.js', './src/lib/FormSelect.js', './src/lib/FormCalendar.js', './src/lib/FormList.js', './src/lib/FormTab.js', './src/lib/FormTable.js', './src/lib/FormMultiInput.js', './src/lib/FormPercent.js', './src/lib/FormUpload.js', './src/lib/ComponentManage.js','./src/lib/ModalDialog.js'])
.pipe(sourcemaps.init())
.pipe(concat('componment.js'))
// .pipe(uglify())
// .pipe(sourcemaps.write())
.pipe(gulp.dest('dist/js'));
gulp.src(['./src/demo/main.js', './src/demo/js/*.js'])
.pipe(sourcemaps.init())
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/js'));
});
gulp.task('uglifyJS1', function() {
gulp.src(['./src/demo/jquery-1.12.4.min.js','./src/demo/prettify.min.js', './src/lib/reasy-ui.js', './src/lib/BaseComponent.js', './src/lib/FormInput.js', './src/lib/FormCheckbox.js', './src/lib/FormCheckList.js', './src/lib/FormRadioList.js', './src/lib/FormDropDownList.js', './src/lib/FormSelect.js', './src/lib/FormCalendar.js', './src/lib/FormList.js', './src/lib/FormTab.js', './src/lib/FormTable.js', './src/lib/FormMultiInput.js', './src/lib/FormPercent.js', './src/lib/FormUpload.js', './src/lib/ComponentManage.js','./src/lib/ModalDialog.js'])
.pipe(concat('componment.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/js'));
gulp.src(['./src/demo/main.js', './src/demo/js/*.js'])
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/js'));
});
gulp.task('minifyCss', function() {
gulp.src(['./src/demo/*.scss','./src/demo/*.css','./src/lib/css/*.scss'])
.pipe(sourcemaps.init())
.pipe(concat('min.css'))
.pipe(sass().on('error', sass.logError))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('dist/css'));
});
gulp.task('minifyCss1', function() {
gulp.src(['./src/demo/*.scss','./src/demo/*.css','./src/lib/css/*.scss'])
.pipe(concat('min.css'))
.pipe(sass().on('error', sass.logError))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('dist/css'));
});
gulp.task('other', function(){
gulp.src(['./src/demo/*.html']).pipe(gulp.dest('dist'));
gulp.src(['./src/demo/main.js']).pipe(gulp.dest('dist/js'));
// gulp.src(['./src/demo/js/*.js']).pipe(gulp.dest('dist/js'));
gulp.src(['./src/lib/css/icon-font/*']).pipe(gulp.dest('dist/css/icon-font'));
gulp.src(['./src/lib/css/icon-font/fonts/*']).pipe(gulp.dest('dist/css/icon-font/fonts'));
gulp.src(['./src/demo/data/*']).pipe(gulp.dest('dist/data'));
});
// gulp.task('revJs', function(){
// return gulp.src([])
// .pipe(rev())
// .pipe(rev.manifest())
// .pipe(gulp.dest('rev/js'));
// });
// gulp.task('revHtml', function () {
// return gulp.src(['rev/**/*.json', 'WEB-INF/views/*.html']) /*WEB-INF/views是本地html文件的路径,可自行配置*/
// .pipe(revCollector())
// .pipe(gulp.dest('WEB-INF/views')); /*Html更换css、js文件版本,WEB-INF/views也是和本地html文件的路径一致*/
// });
// 监视文件改动并重新载入
gulp.task('connect',function(){
connect.server({
root:'./dist',
ip:'127.0.0.1',
port: '8088',
livereload:true
})
});
gulp.task('watch',function(){
gulp.watch(['src/**', './gulpfile.js'], ['default']);
});
gulp.task('server',['connect', 'watch']);
gulp.task('default',['minifyCss', 'uglifyJS', 'other']);
gulp.task('product',['minifyCss1', 'uglifyJS1', 'other']);