-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.babel.js
54 lines (46 loc) · 1.46 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
'use strict';
import gulp from 'gulp';
import sass from 'gulp-sass';
import autoprefixer from 'gulp-autoprefixer';
import sourcemaps from 'gulp-sourcemaps';
import browserify from 'browserify';
import babelify from 'babelify';
import buffer from 'vinyl-buffer';
import util from 'gulp-util';
import concat from 'gulp-concat';
import source from 'vinyl-source-stream';
import browserSync from 'browser-sync';
let browser = browserSync.create();
const paths = {
src: 'src',
dest: 'dist'
};
gulp.task('styles', () => {
return gulp.src(paths.src + '/*.sass')
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoprefixer())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(paths.dest));
});
gulp.task('build', function() {
browserify(paths.src + '/app.js', { debug: true })
.transform(babelify)
.bundle()
.on('error', util.log.bind(util, 'Browserify Error'))
.pipe(source('all.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(paths.dest));
});
gulp.task('serve', () => {
browser.init({
server: './'
});
gulp.watch('src/app.sass', ['styles']);
gulp.watch('src/**/*.js', ['build']);
gulp.watch(paths.dest + '/**/*.*').on('change', browser.reload);
gulp.watch('index.html').on('change', browser.reload);
});
gulp.task('default', ['styles', 'build', 'serve']);