-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
49 lines (40 loc) · 1.23 KB
/
Copy pathgulpfile.js
File metadata and controls
49 lines (40 loc) · 1.23 KB
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
var gulp = require('gulp'),
babel = require('gulp-babel'),
rename = require('gulp-rename'),
browserSync = require('browser-sync');
gulp.task('transpile', function() {
return gulp.src('src/**/*.es6.js')
.pipe(babel({
"optional": [
"es7.decorators",
"runtime",
"optimisation.modules.system"
]
}))
.pipe(rename(function (path) {
path.basename = path.basename.replace(/.es6$/, '');
}))
.pipe(gulp.dest('app/js'));
});
gulp.task('serve', ['transpile'], function(done) {
browserSync({
open: false,
port: 8000,
server: {
baseDir: ['./app'],
middleware: function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
next();
}
}
}, done);
});
//Note: Live reload only works if your HTML file has a <body> tag
gulp.task('watch', function() {
function reportChange(event){
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
}
gulp.watch(['src/**/*.es6.js'], ['transpile', browserSync.reload]).on('change', reportChange);
gulp.watch(['app/**/*.html'], [browserSync.reload]).on('change', reportChange);
});
gulp.task('default', ['serve','watch']);