-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
91 lines (81 loc) · 2.09 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
var gulp = require('gulp');
var karma = require('karma').server;
var watch = require('gulp-watch');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var image = require('gulp-image');
var compass = require('gulp-compass');
var minifyCSS = require('gulp-minify-css');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var rename = require('gulp-rename');
var paths = {
src: {
bower: './src/bower_components',
js: './src/js',
scss: './src/scss',
img: './src/img'
},
dist: {
js: './dist/js',
css: './dist/css',
img: './dist/img'
},
karmaConf: __dirname + '/karma.conf.js'
};
var handleError = function(err) {
console.log(err.toString());
this.emit('end');
};
gulp.task('browserify', function(){
return gulp.src(paths.src.js + '/app.js')
.pipe(browserify())
.pipe(rename('app.bundled.js'))
.pipe(gulp.dest(paths.src.js));
});
gulp.task('javascript', function() {
return gulp.src([
paths.src.js + '/app.js'
])
.pipe(concat('app.min.js'))
.pipe(uglify({
beautify: true
}))
.on('error', handleError)
.pipe(gulp.dest(paths.dist.js));
});
gulp.task('lint', function() {
return gulp.src(paths.src.js + '/app.bundled.js')
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
gulp.task('image', function() {
return gulp.src(paths.src.img + '/**/*')
.pipe(image())
.on('error', handleError)
.pipe(gulp.dest(paths.dist.img));
});
gulp.task('compass', function() {
return gulp.src(paths.src.scss + '/app.scss')
.pipe(compass({
css: paths.dist.css,
sass: paths.src.scss,
image: paths.dist.img,
require: ['breakpoint']
}))
.on('error', handleError)
.pipe(minifyCSS())
.pipe(gulp.dest(paths.dist.css));
});
gulp.task('test', function(done){
karma.start({
configFile: paths.karmaConf,
singleRun: true
}, done);
});
gulp.task('watch', function() {
gulp.watch(paths.src.img + '/**/*', ['image']);
gulp.watch(paths.src.scss + '/**/*.scss', ['compass']);
gulp.watch(paths.src.js + '/**/*.js', ['lint', 'javascript']);
});
gulp.task('default', ['compass', 'image', 'lint', 'javascript', 'watch']);