-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
53 lines (48 loc) · 1.52 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
// gulpfile.js
const gulp = require('gulp');
const babel = require('babelify');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const browserSync = require('browser-sync');
const reload = browserSync.reload;
const notify = require('gulp-notify');
const sass = require('gulp-sass');
const plumber = require('gulp-plumber');
const concat = require('gulp-concat');
gulp.task('styles', () => {
return gulp.src('./dev/styles/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(concat('style.css'))
.pipe(gulp.dest('./public/styles'))
});
gulp.task('js', () => {
browserify('dev/scripts/app.js', {debug: true})
.transform('babelify', {
sourceMaps: true,
presets: ['es2015','react']
})
.bundle()
.on('error',notify.onError({
message: "Error: <%= error.message %>",
title: 'Error in JS 💀'
}))
.pipe(source('app.js'))
.pipe(buffer())
.pipe(gulp.dest('public/scripts'))
.pipe(reload({stream:true}));
});
const historyApiFallback = require('connect-history-api-fallback');
gulp.task('bs', () => {
browserSync.init({
server: {
baseDir: './'
},
middleware: [historyApiFallback()]
});
});
gulp.task('default', ['js','bs', 'styles'], () => {
gulp.watch('dev/**/*.js',['js']);
gulp.watch('dev/**/*.scss',['styles']);
gulp.watch('./public/styles/style.css',reload);
});