Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
node-course/gulpfile.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
62 lines (52 sloc)
1.39 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var jshint = require('gulp-jshint'); | |
var jscs = require('gulp-jscs'); | |
var nodemon = require('gulp-nodemon'); | |
var jsFiles = ['*.js', 'src/**/*.js']; | |
var port = 8080; | |
gulp.task('style', function () { | |
return gulp.src(jsFiles) | |
.pipe(jshint()) | |
.pipe(jshint.reporter('jshint-stylish', { | |
verbose: true | |
})) | |
.pipe(jscs()) | |
.pipe(jscs.reporter()); | |
}); | |
gulp.task('inject', function () { | |
var wiredep = require('wiredep').stream; | |
var inject = require('gulp-inject'); | |
var options = { | |
bowerJson: require('./bower.json'), | |
directory: './public/lib', | |
ignorePath: '../../public' | |
}; | |
var injectSrc = gulp.src([ | |
'./public/css/*.css', | |
'./public/js/*.js' | |
], { | |
read: false | |
}); | |
var injectOptions = { | |
ignorePath: '/public' | |
}; | |
return gulp.src('./src/views/*.html') | |
.pipe(wiredep(options)) | |
.pipe(inject(injectSrc, injectOptions)) | |
.pipe(gulp.dest('./src/views')); | |
}); | |
// will run the dependencies asynchronously | |
gulp.task('serve', ['style', 'inject'], function () { | |
var options = { | |
script: 'app.js', | |
delayTime: 1, | |
env: { | |
'PORT': port | |
}, | |
watch: jsFiles | |
}; | |
return nodemon(options) | |
.on('restart', function (ev) { | |
console.log('Restarting...'); | |
}); | |
}); |