Skip to content

Commit

Permalink
The gulp file was improved functionality.Now, it's watch server files…
Browse files Browse the repository at this point in the history
… and trigger reload.
  • Loading branch information
gorkemerdogann committed Mar 30, 2016
1 parent a0ebeb9 commit 66d0135
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,46 @@ var gulp = require('gulp'),
uglify = require('gulp-uglify'),
cleanCSS = require('gulp-clean-css');

//Prepare paths variable for resources.
var paths = {
scripts: 'dev/js/',
stylesheets: 'dev/css/',
routes: 'routes/'
};

//Building javascript files and copy to public folder. Watch to dev/js folder for actions
gulp.task('build-js', function () {
return gulp.src(paths.scripts + "**/*.js")
.pipe(uglify())
.pipe(gulp.dest('public/js/'));
});
gulp.watch('dev/js/**/*.js', function (file) {
console.log('File ' + file.path + ' was ' + file.type + ', running tasks...');
gulp.start('build-js');
});

//Building stylesheets and copy to public folder. Watch to dev/css folder for actions
gulp.task('build-css', function () {
return gulp.src(paths.stylesheets + "**/*.css")
.pipe(cleanCSS())
.pipe(gulp.dest('public/css/'));
console.log('css exported');
});
gulp.watch('dev/css/**/*.css', function (file) {
console.log('File ' + file.path + ' was ' + file.type + ', running tasks...');
gulp.start('build-css');
});


//Server start and
gulp.task('serve', function () {
//1. run your script as a server
var server = gls.new('./bin/www', {env: {DEBUG: 'jLabWeb:*'}});
server.start();

//use gulp.watch to trigger server actions(notify, start or stop)
gulp.watch(['app.js', './bin/www', 'routes/*.js', 'dev/js/**/*.js', 'dev/css/**/*.css'], function (file) {
gulp.watch(['app.js', './bin/www', 'routes/*.js', './dev/utils/**/*.js'], function (file) {
console.log('File ' + file.path + ' was ' + file.type + ', running tasks...');
server.start.bind(server)();
server.notify.bind(server)(file);
});
});
Expand Down

0 comments on commit 66d0135

Please sign in to comment.