-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·86 lines (79 loc) · 2.12 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var gulp = require('gulp');
var sass = require("gulp-sass");
var nodemon = require("gulp-nodemon");
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
// var sourcemaps = require("gulp-sourcemaps");
// var autoprefixer = require("gulp-autoprefixer");
// var imagemin = require("gulp-imagemin");
// var plumber = require("gulp-plumber");
var SOURCES = {
sass: "public/assets/styles/scss/**/*.scss",
html: "public/app/views/**/*.html",
img: "public/assets/img/**/*"
};
// gulp.task('sass', function () {
// return gulp.src(SOURCES.sass)
// .pipe(sass().on('error', sass.logError))
// .pipe(gulp.dest('./public/assets/styles'));
// });
//
// gulp.task('nodemon', function () {
// nodemon({
// script: 'server.js',
// ext: 'js scss html'
// })
// .on('start', ['watch'])
// .on('change', ['watch'])
// .on('restart', function () {
// console.log('Restarted');
// });
// });
//
// // gulp.task('sass:watch', function () {
// // gulp.watch(SOURCES.sass, ['sass']);
// // });
//
// gulp.task('default', ['nodemon', 'sass'], function () {
// gulp.watch(SOURCES.sass, ['sass']);
// });
gulp.task('sass', function () {
return gulp.src(SOURCES.sass)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./public/assets/styles'))
.pipe(reload({stream: true}));
});
gulp.task('browser-sync', ['nodemon'], function () {
browserSync.init({
proxy: "http://localhost:8888/",
port: 8889,
notify: true,
});
});
gulp.task('nodemon', function (cb) {
var called = false;
return nodemon({
script: 'server.js',
ext: 'js',
ignore: [
'gulpfile.js',
'node_modules/'
]
})
.on('start', function () {
if (!called) {
called = true;
cb();
}
})
.on('restart', function () {
setTimeout(function () {
reload({ stream: false });
}, 1000);
console.log('Restarted!');
});
});
gulp.task('default', ['sass', 'browser-sync'], function () {
gulp.watch([SOURCES.sass], ['sass']);
gulp.watch([SOURCES.html], reload);
});