var connect = require('gulp-connect');
var gulp = require('gulp');
var livereload = require('gulp-livereload');
var watch = require('gulp-watch');
gulp.task('default', function() {
gulp.run('server');
gulp.watch('src/jade/**', function(event) {
gulp.run('jade');
});
gulp.watch('src/css/**', function(event) {
gulp.run('postcss');
});
gulp.watch('src/images/**/*', batch(function (events, done) {
gulp.start('images', done);
}));
});
// Server
gulp.task('server', function() {
connect.server({
root: 'dist',
livereload: true
});
});
azat@pc:~/git/lasttest$ gulp
[19:30:48] Using gulpfile ~/git/lasttest/gulpfile.js
[19:30:48] Starting 'default'...
gulp.run() has been deprecated. Use task dependencies or gulp.watch task triggering instead.
[19:30:48] Starting 'server'...
[19:30:48] Finished 'server' after 9.36 ms
[19:30:48] Finished 'default' after 32 ms
events.js:85
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at exports._errnoException (util.js:746:11)
at Server._listen2 (net.js:1156:14)
at listen (net.js:1182:10)
at Server.listen (net.js:1267:5)
at ConnectApp.server (/home/azat/git/lasttest/node_modules/gulp-connect/index.js:57:19)
at new ConnectApp (/home/azat/git/lasttest/node_modules/gulp-connect/index.js:37:10)
at Object.module.exports.server (/home/azat/git/lasttest/node_modules/gulp-connect/index.js:170:12)
at Gulp.<anonymous> (/home/azat/git/lasttest/gulpfile.js:112:11)
at module.exports (/home/azat/git/lasttest/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/home/azat/git/lasttest/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
azat@pc:~/git/lasttest$
gulp.task('default', ['server'], function() {
gulp.watch('src/jade/**', ['jade']);
gulp.watch('src/css/**', ['postcss']);
gulp.watch('src/images/**/*.@(png|jpg)', ['images']);
});
gulp.task('js',function(){
return gulp.src('./assets/js/*.js')
.pipe(doSomeStuff());
});
var merge = require('merge-stream');
gulp.task('js',function(){
merged = merge();
[
'mdpi', 'hdpi', 'xhdpi'
].forEach(function(density) {
merged.add(gulp.src('app/images/**/*.@(png|gif|jpeg)')
.pipe(doSomeMagicStuff()))
.pipe(gulp.dest('dist/images/' + density)));
});
return merged;
});
var plato = require('plato');
gulp.task('plato', function(done) {
plato.inspect('app/**/*.js', 'reports', {}, function(reports) {
done();
});
});