initial commit, starting from prototool
This commit is contained in:
87
gulpfile.js
Normal file
87
gulpfile.js
Normal file
@@ -0,0 +1,87 @@
|
||||
var gulp = require('gulp');
|
||||
var gutil = require('gulp-util');
|
||||
var gless = require('gulp-less');
|
||||
var gclint = require('gulp-coffeelint');
|
||||
var gcoffee = require('gulp-coffee');
|
||||
var _ = require('lodash');
|
||||
var lr = require('tiny-lr');
|
||||
var static = require('node-static');
|
||||
var exec = require('child_process').exec;
|
||||
|
||||
var server = lr();
|
||||
|
||||
var config = {
|
||||
paths: {
|
||||
less: {
|
||||
src: 'src/less/**/*.less',
|
||||
dest: 'public/css'
|
||||
},
|
||||
coffee: {
|
||||
src: 'src/coffee/**/*.coffee',
|
||||
dest: 'public/js'
|
||||
}
|
||||
},
|
||||
webport: 8080,
|
||||
lrport: 35729
|
||||
};
|
||||
|
||||
gulp.task('less', function() {
|
||||
gulp.src(config.paths.less.src)
|
||||
.pipe(gless({ sourceMap: true }))
|
||||
.pipe(gulp.dest(config.paths.less.dest));
|
||||
});
|
||||
|
||||
gulp.task('lint', function() {
|
||||
gulp.src(config.paths.coffee.src)
|
||||
.pipe(gclint());
|
||||
});
|
||||
|
||||
gulp.task('coffee', ['lint'], function() {
|
||||
gulp.src(config.paths.coffee.src)
|
||||
.pipe(gcoffee({ bare: true }))
|
||||
.pipe(gulp.dest(config.paths.coffee.dest));
|
||||
});
|
||||
|
||||
gulp.task('tiny', function(next) {
|
||||
server.listen(config.lrport, function(err) {
|
||||
if (err) {
|
||||
return console.error(err);
|
||||
}
|
||||
gutil.log('Server listening on port: ', config.lrport);
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('server', function(next) {
|
||||
var file = new static.Server('./public', { cache: false });
|
||||
require('http').createServer(function(req, res) {
|
||||
req.addListener('end', function() {
|
||||
file.serve(req, res);
|
||||
}).resume();
|
||||
}).listen(config.webport, function() {
|
||||
gutil.log('Server listening on port: ', config.webport);
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('open', function(next) {
|
||||
exec('open http://localhost:' + config.webport, function() {
|
||||
next();
|
||||
});
|
||||
})
|
||||
|
||||
gulp.task('watch', ['tiny'], function () {
|
||||
gulp.watch(config.paths.less.src, ['less']);
|
||||
gulp.watch(config.paths.coffee.src, ['coffee']);
|
||||
|
||||
gulp.watch(['./public/**/*', '!./public/vendor/**/*'], function(e) {
|
||||
gutil.log('Notifying browser of changes');
|
||||
server.changed({
|
||||
body: {
|
||||
files: [e.path]
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('default', ['less', 'coffee', 'server', 'watch']);
|
||||
Reference in New Issue
Block a user