-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
66 lines (58 loc) · 1.71 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
var
gulp = require('gulp'),
runSequence = require('run-sequence'),
sourcemaps = require('gulp-sourcemaps'),
babel = require('gulp-babel'),
concat = require('gulp-concat'),
watch = require('gulp-watch'),
batch = require('gulp-batch'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
clean = require('gulp-clean');
var allJS = ['src/common/commonUtil.js',
'src/common/commonComponent.js',
'src/RecentWordPlugin.js',
'src/RecentWordPluginLocalStorageAddOn.js',
'src/TTViewPlugin.js',
'src/SweetSearch.js'];
gulp.task('cleanDist', function() {
gulp.src("dist/*.*", {read: false})
.pipe(clean())
});
//development. AMD(for requireJS)
//TODO. move to upper variables src files"
gulp.task('compileBabelAMD', function() {
gulp.src(allJS)
.pipe(concat('ss_merge_es5.js'))
.pipe(sourcemaps.init())
.pipe(babel({
//for supporting this below code, you have to add 'module export' code in source.
//plugins: ['transform-es2015-modules-amd'],
}))
.pipe(babel({
presets: ['es2015']
}))
//.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'))
});
gulp.task('lint', function() {
return gulp.src('./src/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'));
});
gulp.task('buildJS', function() {
runSequence(
'cleanDist', 'compileBabelAMD'
);
});
gulp.task('watchSS', function() {
watch(['src/*.js', 'src/common/*.js'] , batch(function(events, done) {
gulp.start('buildJS', done);
}));
});
gulp.task('default', function() {
runSequence(
'buildJS', 'jsBuild' //use Array for parallel work.
);
});