-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
55 lines (50 loc) · 1.14 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
54
55
var path = require('path');
var gulp = require('gulp');
var notify = require("gulp-notify");
var changed = require('gulp-changed');
var babel = require('gulp-babel');
var sourcemaps = require('gulp-sourcemaps');
var rimraf = require('rimraf');
var files = {
src: [
'./src/**/*.js',
],
};
// clean build files
gulp.task('clean', function(done) {
rimraf.sync('./build');
done();
});
// build source files
gulp.task('build', function() {
return gulp
.src(files.src)
.pipe(changed('./dist'))
.pipe(sourcemaps.init())
.pipe(babel({
presets: [
'stage-0',
'es2015',
'react',
],
}))
.on('error', notify.onError({
title: 'babel fail',
message: '<%= error.message %>',
}))
.pipe(sourcemaps.write({
includeContent: false,
sourceRoot: function(file) {
return path.resolve(__dirname, 'src');
},
}))
.pipe(gulp.dest('./dist'));
});
// watching source files
gulp.task('watch', function() {
gulp.watch(files.src, ['build']);
});
// run gulp tasks
gulp.task('default', function() {
gulp.start('clean', 'build', 'watch');
});