-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
40 lines (35 loc) · 1.29 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
/* File: gulpfile.js */
// grab our packages
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
bowerFiles = require('main-bower-files'),
inject = require('gulp-inject'),
es = require('event-stream'),
watch = require('gulp-watch'),
debug = require('gulp-debug');
// define the default task and add the watch task to it
gulp.task('default', ['inject','watch']);
gulp.task('inject', function () {
function getMinifiedMainBowerFiles() {
return bowerFiles().map(function(file){ return file.replace('.css','.min.css').replace('.js','.min.js') })
}
return gulp.src('./index.html')
.pipe(inject(gulp.src(getMinifiedMainBowerFiles(), {read: false}),{name: 'bower'}))
.pipe(inject(es.merge(
gulp.src('./src/**/*.css', {read: false}),
gulp.src('./src/**/*.js', {read: false}))), {relative: true})
.pipe(gulp.dest('./'));
});
// configure the jshint task
gulp.task('jshint', function() {
return gulp.src('src/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
// configure which files to watch and what tasks to use on file changes
gulp.task('watch', function() {
gulp.watch('./src/**/*.js', ['jshint']);
watch(['./src/**/*.js','./bower_components/**/*.js','./src/**/*.css','./bower_components/**/*.css'], function(){
gulp.start('inject');
});
});