-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
69 lines (60 loc) · 1.67 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
// Include gulp & gulp plugins
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
less = require('gulp-less'),
connect = require('gulp-connect'),
stylish = require('jshint-stylish'),
plumber = require('gulp-plumber'),
replace = require('gulp-replace'),
gutil = require('gulp-util'),
autoprefixer = require('gulp-autoprefixer');
// Creating error handling exception using gulp-util
var onError = function (err) {
gutil.beep();
console.log(err);
};
// Lint task
gulp.task('lint', function () {
return gulp.src('app/scripts/*.js')
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(connect.reload());
});
// Compile LESS files
gulp.task('less', function () {
return gulp.src(['app/less/style.less'])
.pipe(plumber({
errorHandler: onError
}))
.pipe(less())
.pipe(autoprefixer({
browsers: ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1', 'IE 9'],
cascade : true
}))
.pipe(gulp.dest('app/css'))
.pipe(connect.reload());
});
// Server
gulp.task('server', function () {
connect.server({
root : 'app',
port : 2200,
//livereload: true,
fallback : "app/index.html"
});
});
// Html
gulp.task('html', function () {
return gulp.src('/app/views/*.html')
.pipe(connect.reload());
});
// Watch files for changes
gulp.task('watch', function () {
gulp.watch('app/scripts/*.js', ['lint']);
gulp.watch('app/less/*.less', ['less']);
gulp.watch('app/views/*.html', ['html']);
});
// Default task
gulp.task('default', ['server', 'lint', 'less', 'watch']);
// Build task
//gulp.task('build', ['minifyCSS', 'htmlreplace', 'angular']);