-
Notifications
You must be signed in to change notification settings - Fork 224
/
gulpfile.js
41 lines (36 loc) · 1.27 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
///// Gulp Dependencies /////
var gulp = require('gulp'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
cleanCSS = require('gulp-clean-css'),
rename = require("gulp-rename"),
spawn = require('child_process').spawn,
node;
////// Build Tasks ///////
gulp.task('build-sass', function () {
gulp.src('./src/scss/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./src/scss/temp')) //build them here first
.pipe(concat('main.css')) //concat them all
.pipe(gulp.dest('./public/css'))
.pipe(cleanCSS()) //minify
.pipe(rename("main.min.css"))
.pipe(gulp.dest('./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('./src/scss/*.scss', ['build-sass']);
});
gulp.task('watch-server', ['server'], function () {
gulp.watch('./routes/**/*.js', ['server']);
gulp.watch(['./utils/**/*.js', '!./temp/**'], ['server']);
gulp.watch('./setup.js', ['server']);
gulp.watch('./app.js', ['server']);
});
////// Default //////
gulp.task('default', ['watch-sass', 'watch-server'], function(){});