-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
36 lines (29 loc) · 1.09 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
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var proxyMiddleware = require('http-proxy-middleware');
var proxy = proxyMiddleware('/data', {target: 'http://localhost:9003'});
// process JS files and return the stream.
gulp.task('js', function () {
return gulp.src('./app/js/*js')
.pipe(gulp.dest('./app/dist/js'));
});
gulp.task('html', function () {
return gulp.src('./app/*.html')
.pipe(gulp.dest('./app/dist/'));
});
// create a task that ensures the `js` task is complete before
// reloading browsers
gulp.task('js-watch', ['js'], browserSync.reload);
// use default task to launch Browsersync and watch JS files
gulp.task('serve', ['html', 'js'], function () {
// Serve files from the root of thisgulp project
browserSync.init({
server: {
baseDir: "./app/dist/",
middleware: [proxy]
}
});
// add browserSync.reload to the tasks array to make
// all browsers reload after tasks are complete.
gulp.watch("./app/js/*.js", ['js-watch']).on('change', browserSync.reload);
});