forked from arthurbernierjr/progress-and-fortune-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·94 lines (87 loc) · 2.07 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
87
88
89
90
91
92
93
94
const gulp = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync').create();
const reload = browserSync.reload;
var exec = require('child_process').exec;
gulp.task('default', (cb) => {
browserSync.init({
server: './public',
notify: false,
open: true //change this to true if you want the broser to open automatically
});
gulp.watch('./assets/scss/**/*', gulp.task('styles'));
gulp.watch('./assets/js/**/*', gulp.task('webpack'));
gulp
.watch([
'./public/**/*',
'./public/*',
'!public/js/**/.#*js',
'!public/css/**/.#*css'
])
.on('change', reload);
cb()
});
gulp.task('watch-proxy', (cb) => {
gulp.watch('./assets/scss/**/*', gulp.task('styles'));
gulp.watch('./assets/js/**/*', gulp.task('webpack'));
gulp
.watch([
'./public/**/*',
'./public/*',
'!public/js/**/.#*js',
'!public/css/**/.#*css'
])
.on('change', reload);
cb()
});
gulp.task('styles', (cb) => {
gulp
.src('assets/scss/**/*.scss')
.pipe(
sass({
outputStyle: 'compressed'
}).on('error', sass.logError)
)
.pipe(
autoprefixer({
browsers: ['last 2 versions']
})
)
.pipe(gulp.dest('./public/css'))
.pipe(browserSync.stream());
cb()
});
gulp.task('browser-sync', function(cb) {
browserSync.init({
server: './public',
notify: false,
open: false //change this to true if you want the broser to open automatically
});
cb()
});
gulp.task('browser-sync-proxy', function(cb) {
// THIS IS FOR SITUATIONS WHEN YOU HAVE ANOTHER SERVER RUNNING
browserSync.init({
proxy: {
target: 'http://localhost:3333/', // can be [virtual host, sub-directory, localhost with port]
ws: true // enables websockets
}
// serveStatic: ['.', './public']
});
cb()
});
gulp.task('webpack', cb => {
exec('npm run dev:webpack', function(err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('build', cb => {
exec('npm run build:webpack', function(err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});