-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·96 lines (82 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
84
85
86
87
88
89
90
91
92
93
94
95
96
var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sh = require('shelljs');
var del = require('del');
var inject = require('gulp-inject');
var templateCache = require('gulp-angular-templatecache');
var uglify = require('gulp-uglify');
var ngAnnotate = require('gulp-ng-annotate');
var karma = require('karma').Server;
var paths = {
sass: ['./app/scss/**/*.scss'],
scripts: ['app/**/*.js', '!./app/**/*.spec.js']
};
var indexPage = gulp.src('./app/index.html');
function clean() {
return del(['./www/css', './www/js', './www/templates']);
}
function styles(done) {
gulp.src('app/scss/*.scss')
.pipe(sass())
.on('error', sass.logError)
.pipe(minifyCss({
keepSpecialComments: 0
}))
.pipe(rename({
extname: '.min.css'
}))
.pipe(gulp.dest('./www/css/'))
.on('end', done);
}
function copy() {
return gulp.src(paths.scripts)
.pipe(gulp.dest('./www/js/'));
}
function index() {
var sources = gulp.src(['./js/**/*.js', './css/**/*.css'], {
read: false,
cwd: 'www/'
});
return indexPage.pipe(inject(sources, {
addRootSlash: false
}))
.pipe(gulp.dest('./www/'));
}
function templates() {
return gulp.src('./app/**/*.html')
.pipe(templateCache())
.pipe(gulp.dest('./www/js/'));
}
function compress() {
return gulp.src(paths.scripts)
.pipe(concat('all.js'))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(gulp.dest('./www/js/'));
}
function watch() {
gulp.watch('./app/**/*.scss', styles);
gulp.watch('./app/**/*.js', copy);
gulp.watch('./app/**/*.html', templates);
}
gulp.task('test', function(done) {
new karma({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task(clean);
gulp.task(styles);
gulp.task(copy);
gulp.task(templates);
gulp.task(compress);
gulp.task(index);
gulp.task(watch);
gulp.task('debug', gulp.series(clean, gulp.parallel(styles, copy, templates), index, watch));
gulp.task('build', gulp.series(clean, gulp.parallel(styles, compress, templates), index));
gulp.task('default', gulp.series('debug'));