-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (70 loc) · 1.8 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
sourcemaps = require('gulp-sourcemaps'),
eslint = require('gulp-eslint'),
concat = require('gulp-concat'),
ngAnnotate = require('gulp-ng-annotate'),
wiredep = require('wiredep'),
connect = require('gulp-connect');
gulp.task('build:css', function() {
return gulp
.src('app/assets/scss/*.scss')
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoprefixer({
browsers: ['last 3 versions'],
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('app/assets/css'))
.pipe(connect.reload());
});
gulp.task('build:js', function() {
return gulp
.src([
'app/assets/js/main.js',
'app/assets/js/{config,constants,controllers,directives,filters,interceptors,services}/*.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(concat('app.js'))
.pipe(ngAnnotate({
single_quotes: true
}))
.pipe(gulp.dest('app/assets/js'))
.pipe(connect.reload());
});
gulp.task('build', ['build:css', 'build:js']);
gulp.task('lint', function() {
return gulp
.src([
'gulpfile.js',
'app/assets/js/{,*/}*.js',
'tests/{,e2e/,unit/}*.js',
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
gulp.task('serve', function() {
connect.server({
root: 'app',
port: 9000,
livereload: true,
middleware: function() {
var history = require('connect-history-api-fallback');
return [history()];
}
});
});
gulp.task('reload', function() {
return gulp
.src('app/**/*.html')
.pipe(connect.reload());
});
gulp.task('watch', function() {
gulp.watch('app/assets/scss/{,*/}*.scss', ['sass']);
gulp.watch('app/assets/js/{main,*/*}.js', ['build:js']);
gulp.watch('app/{index,views/*,assets/partials/*}.html', ['reload']);
});
gulp.task('default', ['build', 'serve', 'watch']);