-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
69 lines (60 loc) · 1.59 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
'use strict';
var pkg = require('./package.json')
, gulp = require('gulp')
, babel = require('gulp-babel')
, iife = require('gulp-iife')
, concat = require('gulp-concat')
, uglify = require('gulp-uglify')
, clean = require('gulp-clean')
, rename = require('gulp-rename')
, header = require('gulp-header')
, runSeq = require('run-sequence');
gulp.task('default', ['dist', 'watch']);
gulp.task('dist', function() {
runSeq('dist-clean', 'dist-file', 'dist-min');
});
var files = {
src: {
dir: 'src',
all: [
'*.module.js',
'*.service.js',
'*.directive.js'
]
},
dist: {
dir: 'dist',
all: '*.js',
file: 'angular-theme.js',
min: 'angular-theme.min.js'
}
};
var banner = [
'/**',
' * <%= pkg.name %> v<%= pkg.version %>',
' * <%= date %>',
' * <%= pkg.author %>',
' */',
'\n'
].join('\n');
gulp.task('dist-clean', function() {
return gulp.src(files.dist.all, { cwd: files.dist.dir })
.pipe(clean());
});
gulp.task('dist-file', function() {
return gulp.src(files.src.all, { cwd: files.src.dir })
.pipe(babel({ blacklist: ['useStrict'] }))
.pipe(concat(files.dist.file))
.pipe(iife({ prependSemicolon: false }))
.pipe(header(banner, { pkg: pkg, date: new Date() }))
.pipe(gulp.dest(files.dist.dir));
});
gulp.task('dist-min', function() {
return gulp.src(files.dist.file, { cwd: files.dist.dir })
.pipe(uglify())
.pipe(rename(files.dist.min))
.pipe(gulp.dest(files.dist.dir));
});
gulp.task('watch', function () {
gulp.watch(files.src.all, { cwd: files.src.dir }, ['dist']);
});