/
gulpfile.js
53 lines (47 loc) 路 1.3 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
'use strict'
const gulp = require('gulp');
const stylus = require('gulp-stylus');
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 historyApiFallback = require('connect-history-api-fallback');
const notify = require('gulp-notify');
const plumber = require('gulp-plumber');
// const moment = require('moment');
gulp.task('js', () => {
return browserify('src/app.js')
.transform('babelify', {
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/'))
.pipe(reload({stream:true}));
});
gulp.task('styl', function() {
gulp.src('./src/stylus/main.styl')
.pipe(stylus())
.pipe(gulp.dest('./public/'))
.pipe(reload({stream: true}));
});
gulp.task('bs', () => {
browserSync.init({
server: {
baseDir: './'
},
middleware: [historyApiFallback()]
});
});
gulp.task('default', ['js','bs', 'styl'], () => {
gulp.watch('src/**/*.js',['js']);
gulp.watch('./src/stylus/*.styl', ['styl']);
// gulp.watch('src/stylus/main.css', reload);
});