-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (55 loc) · 1.68 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'use strict';
if(!process.env.PORT) {
require('dotenv').config()
}
const gulp = require('gulp'),
path = require('path'),
sass = require('gulp-sass'),
browserSync = require('browser-sync'),
watch = require('gulp-watch'),
nodemon = require('gulp-nodemon'),
pug = require('gulp-pug'),
paths = {
sassDirectory: 'app/sass/**/*.scss',
pugDirectory: ['!app/shared/**', 'app/**/*.pug'],
publicDirectory: './public/',
jsDirectory: 'public/js/**/*.js',
};
gulp.task('pug2html', function() {
gulp.src(paths.pugDirectory)
.pipe(pug())
.pipe(gulp.dest(paths.publicDirectory))
.pipe(browserSync.stream());
});
gulp.task('sass2css', function() {
gulp.src(paths.sassDirectory)
.pipe(sass())
.pipe(gulp.dest(path.join(paths.publicDirectory + 'css/')))
.pipe(browserSync.stream());
});
gulp.task('nodemon', function() {
nodemon({
script: 'index.js',
ext: 'js',
ignore: ['public/', 'node_modules/']
})
.on('restart', function() {
console.log('>> node restart');
});
});
gulp.task('watchJSFiles', function() {
gulp.src(paths.jsDirectory)
.pipe(browserSync.stream());
});
gulp.task('watch&reload', function() {
browserSync.init(null, {
proxy: 'http://localhost:3000',
port: 5000,
browser: 'google chrome'
});
gulp.watch(paths.sassDirectory, ['sass2css']);
gulp.watch(paths.pugDirectory, ['pug2html']);
gulp.watch(paths.jsDirectory, ['watchJSFiles']);
});
gulp.task('build', ['pug2html', 'sass2css']);
gulp.task('default', ['nodemon', 'build', 'watchJSFiles','watch&reload']);