-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
129 lines (109 loc) · 3.31 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
var gulp = require('gulp');
var header = require('gulp-header');
var footer = require('gulp-footer');
var concat = require('gulp-concat');
var prettify = require('gulp-jsbeautifier');
var compress = require('gulp-yuicompressor');
var rename = require('gulp-rename');
var jshint = require('gulp-jshint');
var argv = require('yargs').argv;
var browserSync = require("browser-sync");
var sass = require('gulp-sass');
var reload = browserSync.reload;
/**
* 全局部件
*/
var globWidgets = [
'./src/js/pubsub.js',
'./src/js/alert.js', //活动这边用到的
'./src/js/cookie.js',
'./src/js/loading.js', //活动这边用到的
'./src/js/alert.js', //活动这边用到的
];
/**
* UI组件
* @场景:PC端,IE8+
*/
var pcComponents = [
// './src/js/tooltip.js',
'./src/js/emailSuffix.js', //活动pc这边用到的
'./src/js/placeholder.js', //活动pc这边用到的
'./src/js/typeCount.js',
// './src/js/lrselect.js',
// './src/js/iselector.js', //活动pc这边用到的
'./src/js/tokenize.js',
'./src/js/dialog.js',
'./src/js/popover.js'
];
/**
* UI组件
* @场景:移动端,Android 4.2+ , IOS 6+
*/
var mobileComponents = [
'./src/js/hideNavbar.js',
'./src/js/fresh.js',
'./src/js/panel.js',
'./src/js/mpicker.js' //活动wap这边用到的
];
/**
* UI组件
* @场景:适应多端
*/
var commonComponents = [
'./src/js/layer.js', //活动这边用到的
'./src/js/tabs.js',
'./src/js/share.js', //活动这边用到的
'./src/js/exist.js', //活动这边用到的
'./src/js/ajaxError.js', //活动这边用到的
'./src/js/ajaxForm.js', //活动这边用到的
'./src/js/validate.js', //活动这边用到的
];
/**
* 核心功能
* @描述:包含结构、某些组件需依赖的工具集,强制依赖
*/
var coreUtil = ['./src/js/index.js'];
var headerText = '(function($, window, document, undefined) {';
var footerText = '}(jQuery, window, document, undefined));';
var components = coreUtil.concat(globWidgets, commonComponents, argv.pc ? pcComponents : (argv.mobi ? mobileComponents : pcComponents.concat(mobileComponents)));
/**
* gulp build --pc 编译pc
* gulp build --mobi 编译mobile
*/
gulp.task('build', function() {
gulp.src(components)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(concat('iui.js'))
.pipe(header(headerText))
.pipe(footer(footerText))
.pipe(prettify({ config: '.jsbeautifyrc', mode: 'VERIFY_AND_WRITE' }))
.pipe(gulp.dest('./dist/'))
.pipe(compress({ type: 'js' }))
.pipe(rename('iui.min.js'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('sass', function () {
return gulp.src(['./src/sass/*.scss'])
.pipe(sass({
outputStyle:'expanded',
sourceComments:true,
}).on('error', sass.logError))
.pipe(gulp.dest('./dist'));
});
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: "./"
}
});
});
gulp.task('fresh', function() {
gulp.src(['./examples/**/*.html', './src/js/*.js','./examples/**/*.js']).pipe(reload({
stream: true
}));
});
gulp.task('watch', ['browser-sync', 'sass', 'fresh'], function() {
gulp.watch(['./examples/**/*.html', './src/js/*.js','./examples/**/*.js','./dist/**/*.css'], ['fresh']);
gulp.watch('./src/**/*.scss', ['sass','fresh']);
});