This repository has been archived by the owner on Apr 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
gulpfile.js
84 lines (74 loc) · 2.13 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
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')(),
Karma = require('karma').Server
ngAnnotate = require('gulp-ng-annotate');
var paths = {
scripts: {
src: ['src/**/*.js'],
dest: 'dist',
file: 'mention.js'
},
styles: {
src: ['src/**/*.scss'],
dest: 'dist',
file: 'mention.css'
},
example: {
scripts: {
src: ['example/**/*.es6.js'],
dest: 'example',
file: 'example.js'
},
styles: {
src: ['example/**/*.scss'],
dest: 'example'
}
}
};
gulp.task('scripts', scripts(paths.scripts));
gulp.task('scripts:example', scripts(paths.example.scripts));
gulp.task('styles', styles(paths.styles));
gulp.task('styles:example', styles(paths.example.styles));
gulp.task('default', gulp.series('scripts'));
gulp.task('example', gulp.series('scripts:example', 'styles:example'));
gulp.task('watch', function(){
gulp.watch(paths.scripts.src, gulp.series('scripts'));
gulp.watch(paths.styles.src, gulp.series('styles'));
});
gulp.task('watch:example', function(){
gulp.watch(paths.example.scripts.src, gulp.series('scripts:example'));
gulp.watch(paths.example.styles.src, gulp.series('styles:example'));
});
gulp.task('karma', karma());
gulp.task('watch:karma', karma({ singleRun: false, autoWatch: true }));
function karma (opts) {
opts = opts || {};
opts.configFile = __dirname + '/karma.conf.js';
return function (done) {
return new Karma(opts, done).start();
}
}
function scripts(path, concat) {
return function() {
return gulp.src(path.src)
.pipe(plugins.sourcemaps.init())
.pipe(plugins.babel())
.pipe(plugins.angularFilesort())
.pipe(plugins.concat(path.file))
.pipe(ngAnnotate())
.pipe(gulp.dest(path.dest))
.pipe(plugins.uglify({ mangle: false }))
.pipe(plugins.extReplace('.min.js'))
.pipe(gulp.dest(path.dest))
.pipe(plugins.sourcemaps.write('.'));
}
}
function styles(path) {
return function() {
return gulp.src(path.src)
.pipe(plugins.sourcemaps.init())
.pipe(plugins.sass())
.pipe(gulp.dest(path.dest))
.pipe(plugins.sourcemaps.write('.'));
}
}