-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.js
83 lines (71 loc) · 2.16 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
var gulp = require('gulp');
var args = require('yargs').argv;
var bump = require('gulp-bump');
var del = require('del');
var header = require('gulp-header');
var Server = require('karma').Server;
var less = require('gulp-less');
var cleanCSS = require('gulp-clean-css');
var ngAnnotate = require('gulp-ng-annotate');
var pkg = require('./package.json');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @author <%= pkg.author %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
gulp.task('clean', function () {
return del(['dist/**/*']);
});
gulp.task('copy', ['clean'], function () {
gulp.src('src/*.less')
.pipe(gulp.dest('dist'));
});
gulp.task('js', ['clean', 'test'], function () {
return gulp.src('src/*.js')
.pipe(ngAnnotate({single_quotes: true}))
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest('dist'));
});
gulp.task('compress', ['js'], function () {
return gulp.src('dist/*.js')
.pipe(uglify({preserveComments: 'license'}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist'));
});
gulp.task('scss', ['clean'], function () {
return gulp.src('src/*.less')
.pipe(rename({
prefix: '_',
extname: '.scss'
}))
.pipe(gulp.dest('dist'));
});
gulp.task('less', ['clean'], function () {
return gulp.src('src/*.less')
.pipe(less())
.pipe(gulp.dest('dist'));
});
gulp.task('css', ['less'], function () {
return gulp.src('dist/*.css')
.pipe(cleanCSS())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist'));
});
gulp.task('test', function (done) {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('bump', function () {
return gulp.src('*.json')
.pipe(bump({type: args.type}))
.pipe(gulp.dest('.'));
});
gulp.task('build', ['scss', 'less', 'css', 'copy', 'js', 'compress']);
gulp.task('default', ['clean', 'test', 'build']);