-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
42 lines (37 loc) · 1.46 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
41
42
///// Gulp Dependencies /////
var path = require('path');
var gulp = require('gulp');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var cleanCSS = require('gulp-clean-css');
var rename = require('gulp-rename');
var spawn = require('child_process').spawn;
var node;
////// Build Tasks ///////
gulp.task('build-sass', function () {
gulp.src(path.join(__dirname, '/scss/*.scss'))
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(path.join(__dirname,'/scss/temp'))) //build them here first
.pipe(concat('main.css')) //concat them all
.pipe(gulp.dest(path.join(__dirname, '/public/css')))
.pipe(cleanCSS()) //minify
.pipe(rename('main.min.css'))
.pipe(gulp.dest(path.join(__dirname,'/public/css'))); //dump it here
});
////// Run Server Task ///////
gulp.task('server', function() {
if(node) node.kill();
node = spawn('node', ['app.js'], {stdio: 'inherit'}); //command, file, options
});
////// Watch Tasks //////
gulp.task('watch-sass', ['build-sass'], function () {
gulp.watch(path.join(__dirname, '/scss/*.scss'), ['build-sass']);
});
gulp.task('watch-server', ['server'], function () {
gulp.watch(path.join(__dirname, '/routes/**/*.js'), ['server']);
gulp.watch([path.join(__dirname, '/utils/**/*.js')], ['server']);
gulp.watch(path.join(__dirname, '/setup.js'), ['server']);
gulp.watch(path.join(__dirname, '/app.js'), ['server']);
});
////// Tasks //////
gulp.task('default', ['watch-sass', 'watch-server']);