-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.babel.js
52 lines (44 loc) · 1.31 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
import gulp from 'gulp';
import marked from 'marked';
import rename from 'gulp-rename';
import template from 'gulp-template';
import fs from 'fs';
import data from 'gulp-data';
import browserSync from 'browser-sync';
import streamify from 'gulp-streamify';
import source from 'vinyl-source-stream';
import babelify from 'babelify';
import babel from 'gulp-babel';
import browserify from 'browserify';
import gutil from 'gulp-util';
import uglify from 'gulp-uglify';
gulp.task('build', function () {
let bundler = browserify({ debug: true }),
b;
bundler.transform(babelify);
bundler.add('./fitit.js');
b = bundler.bundle()
.on('error', gutil.log)
.pipe(source('./fitit.js'))
.pipe(gulp.dest('./dist'))
.pipe(streamify(uglify()))
.pipe(rename('fitit.min.js'))
.pipe(gulp.dest('./dist'));
return gulp.src('./index.html.template')
.pipe(data( () => ({
content: marked(fs.readFileSync('README.md', 'utf8'))
}))
)
.pipe(template())
.pipe(rename('index.html'))
.pipe(gulp.dest('./'));
});
gulp.task('start-server', function () {
browserSync({
server: {
baseDir: "./"
}
});
});
gulp.task('default', ['build', 'start-server']);
gulp.watch('*.*', ['build']);