-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
61 lines (52 loc) · 1.56 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
var cleanCss = require('gulp-clean-css');
var concat = require('gulp-concat');
var del = require('del');
var gulp = require('gulp');
var gutil = require('gulp-util');
var ngAnnotate = require('gulp-ng-annotate');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
/**
* Directories
*/
var javascriptGlob = [
'./app/ng/modules/**/*.js',
'./app/ng/config/**/*.js',
'./app/ng/run/**/*.js',
'./app/ng/**/*.js'
];
var stylesGlob = [
'./app/sass/**/*.scss'
];
/**
* Tasks
*/
gulp.task('default', ['javascript', 'styles']);
gulp.task('clean', () => {
del.sync('./app/dist');
});
gulp.task('javascript', () => {
return gulp.src(javascriptGlob)
.pipe(concat('app.min.js'))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(gulp.dest('./app/dist/js'));
});
gulp.task('styles', () => {
return gulp.src('./app/sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(cleanCss())
.pipe(gulp.dest('./app/dist/css'));
});
gulp.task('watch', () => {
var sassWatcher = gulp.watch(stylesGlob, ['styles']);
generateWatcherListener(sassWatcher, 'styles');
var javascriptWatcher = gulp.watch(javascriptGlob, ['javascript']);
generateWatcherListener(javascriptWatcher, 'javascript');
});
function generateWatcherListener(watcher, taskType) {
watcher.on('change', function(event) {
var displayPath = gutil.colors.yellow(event.path.replace(__dirname + '/', ''));
gutil.log('File', displayPath, 'was', event.type + ', recompiling ' + taskType + '...');
});
}