-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
90 lines (76 loc) · 1.98 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
const {src, dest, series, parallel} = require('gulp')
const watch = require('glob-watcher')
const webpack = require('webpack-stream')
const browserSync = require('browser-sync').create();
const nodemon = require('gulp-nodemon');
const del = require('del')
const named = require('vinyl-named')
const sourcemaps = require('gulp-sourcemaps');
const sass = require('gulp-sass');
function clean(){
return del([
'./dist/scripts/**',
'./dist/styles/**'
])
}
async function bsTask(){
console.log('this is bs');
return browserSync.init({
proxy: "localhost:3000",
port: 3001
})
}
async function nodemonTask(cb) {
return nodemon( {
script: './bin/www',
ext: 'js html',
env: { 'NODE_ENV': 'development' },
port: 3000,
done: cb()
})//.once('start', cb);
};
function scripts(){
return src(['./src/scripts/**.js',
])
.pipe(sourcemaps.init())
.pipe(named())
.pipe(webpack({
mode: 'development'
}))
.pipe(sourcemaps.write())
.pipe(dest('dist/scripts/'));
}
function styles(){
return src('./src/styles/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(dest('dist/styles/'))
.pipe(browserSync.stream())
}
function vendors(){
return src([''])
.pipe(dest('dist/vendors/'))
}
function images(){
return src(['./src/images/**/**'])
.pipe(dest('dist/images/'))
}
const dev = series(
clean,
//vendors,
scripts,
parallel(
styles,
images
)
)
async function watcher(){
watch(['./src/styles/**/*.scss'], styles )
watch( [ `./src/scripts/**/**`, `./src/views/**/*.pug`], ()=>{
series(
dev(),
setTimeout(browserSync.reload,2000)
)
});
}
const run = series(dev, watcher, nodemonTask, bsTask);
module.exports = {dev, watcher, run}