-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
58 lines (47 loc) · 1.11 KB
/
gulpfile.babel.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
import gulp from 'gulp';
import run from 'run-sequence';
import server from 'gulp-live-server';
import rimraf from 'rimraf';
import shell from 'gulp-shell';
import sass from 'gulp-sass';
import sync from 'browser-sync';
let express;
const paths = {
js: './src/**/*.js',
sass: './src/sass/**/*.scss',
dest: './app'
}
gulp.task('browser-sync', function() {
sync.init({
proxy: "localhost:1337"
});
});
gulp.task('default', ()=> {
run('server', 'build', 'watch');
});
gulp.task('build', ()=>{
run('clean', 'babel', 'restart');
});
gulp.task('clean', cb=>{
rimraf(paths.dest, cb);
});
gulp.task('babel', shell.task([
'babel src --out-dir app'
]));
gulp.task('sass', ()=>{
return gulp
.src(paths.sass)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./public/css'))
.pipe(sync.stream());
});
gulp.task('server', ()=>{
express = server.new(paths.dest + '/app.js');
});
gulp.task('restart', ()=>{
express.start.bind(express)();
});
gulp.task('watch', ['browser-sync'], ()=>{
gulp.watch(paths.sass, ['sass']);
gulp.watch(paths.js, ['build']);
});