forked from OiWorld/MindTheWord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
95 lines (82 loc) · 2.64 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
var gulp = require('gulp'),
del = require('del'),
jspm = require('gulp-jspm'),
rename = require('gulp-rename'),
runSequence = require('run-sequence'),
minify = require('gulp-minify');
gulp.task('default', function() {
console.log('Please use the following gulp tasks: watch, clean, bundle, build');
});
gulp.task('clean', function() {
return del('./dist', {
force: true
});
});
gulp.task('bundle-options', function() {
return gulp.src('./lib/scripts/controllers/options.js')
.pipe(jspm({
selfExecutingBundle: true
}))
.pipe(rename('options.js'))
.pipe(gulp.dest('./lib'));
});
gulp.task('bundle-popup', function() {
return gulp.src('./lib/scripts/controllers/popup.js')
.pipe(jspm({
selfExecutingBundle: true
}))
.pipe(rename('popup.js'))
.pipe(gulp.dest('./lib'));
});
gulp.task('bundle-event', function() {
return gulp.src('./lib/scripts/eventPage.js')
.pipe(jspm({
selfExecutingBundle: true
}))
.pipe(rename('eventPage.js'))
.pipe(gulp.dest('./lib'));
});
gulp.task('bundle-content', function() {
return gulp.src('./lib/scripts/mtw.js')
.pipe(jspm({
selfExecutingBundle: true
}))
.pipe(rename('mtw.js'))
.pipe(gulp.dest('./lib'));
});
gulp.task('watch', ['bundle-options', 'bundle-popup', 'bundle-content', 'bundle-event'], function() {
gulp.watch('./lib/scripts/controllers/options.js', ['bundle-options']);
gulp.watch('./lib/scripts/controllers/popup.js', ['bundle-popup']);
gulp.watch('./lib/scripts/mtw.js', ['bundle-content']);
gulp.watch('./lib/scripts/eventPage.js', ['bundle-event']);
gulp.watch('./lib/scripts/services/*.js', ['bundle-content', 'bundle-event']);
gulp.watch('./lib/scripts/utils/defaultStorage.js', ['bundle-options','bundle-event']);
});
gulp.task('minify', function () {
return gulp.src('./lib/*.js')
.pipe(minify({
ext: {
min: '.js'
},
noSource: true,
mangle: false
}))
.pipe(gulp.dest('./dist'));
});
gulp.task('copy-dist', function () {
gulp.src('./lib/_locales/**/*').pipe(gulp.dest('./dist/_locales/'));
gulp.src('./lib/assets/**/*').pipe(gulp.dest('./dist/assets/'));
gulp.src('./lib/styles/**/*').pipe(gulp.dest('./dist/styles/'));
gulp.src('./lib/views/**/*').pipe(gulp.dest('./dist/views/'));
return gulp.src('./lib/manifest.json').pipe(gulp.dest('./dist/'));
});
gulp.task('build', function() {
runSequence('clean',
['bundle-content', 'bundle-options', 'bundle-event',
'bundle-popup'], 'minify', 'copy-dist');
});
gulp.task('local-build', function() {
runSequence('clean',
['bundle-content', 'bundle-options', 'bundle-event',
'bundle-popup']);
});