-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
60 lines (49 loc) · 1.52 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
'use strict';
const gulp = require('gulp');
const sass = require('gulp-sass');
const exec = require('child_process').exec;
const browserSync = require('browser-sync');
const clean = require('gulp-clean');
const rename = require('gulp-rename');
const ENV = require('./environment');
gulp.task('browser-sync', function() {
// var port = process.env.PORT || 3000;
browserSync.init({
// see http://www.browsersync.io/docs/options/
server: {
baseDir: './build'
}
});
});
gulp.task('sass', function () {
return gulp.src('./src/styles/**/style.scss')
.pipe(sass({
outputStyle: 'compressed',
includePaths: ['node_modules']
}).on('error', sass.logError))
.pipe(rename(ENV.styleName))
.pipe(gulp.dest('./public'));
});
gulp.task('nodemon', function (cb) {
exec('nodemon app.js', function (err, stdout, stderr) {
// console.log(stderr);
cb(err);
});
})
gulp.task('watch', ['browser-sync'], function () {
gulp.watch('./src/**/*.js', ['nodemon']);
gulp.watch('./src/**/*.scss', ['sass']);
gulp.watch('./build/**/*.*', browserSync.reload);
gulp.watch('./app.js', browserSync.reload);
});
gulp.task('clean:images', function () {
return gulp.src('./images/**/*', {read: false})
.pipe(clean());
});
gulp.task('clean:build', function () {
return gulp.src('./build', {read: false})
.pipe(clean());
});
gulp.task('clean', ['clean:images', 'clean:build']);
gulp.task('dev', ['nodemon', 'sass']);
gulp.task('default', ['dev', 'watch']);