-
Notifications
You must be signed in to change notification settings - Fork 59
/
gulpfile.js
85 lines (72 loc) · 1.84 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* RxJS in action
* Chapter #
* @author Paul Daniels
* @author Luis Atencio
*/
'use strict';
// Gulp
const gulp = require('gulp');
const connect = require('gulp-connect');
const sourcemaps = require('gulp-sourcemaps');
// Http server stuff
const proxy = require('http-proxy-middleware');
const serveStatic = require('serve-static');
const bodyParser = require('body-parser');
// Rollup
const rollup = require('rollup-stream');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const babel = require('rollup-plugin-babel');
const nodeResolve = require('rollup-plugin-node-resolve');
// Our modules
const api = require('./api');
gulp.task('default', ['build', 'connect', 'watch']);
gulp.task('build', ['rollup', 'copy']);
let cache = null;
gulp.task('rollup', function() {
return rollup({
entry: './app/js/runtime.js',
sourceMap: true,
format: 'iife',
plugins: [babel({
exclude: 'node_modules/**'
})],
globals: {
'rxjs': 'Rx',
'jquery': '$',
'codemirror': 'CodeMirror'
},
cache: cache
})
.on('bundle', function(bundle) {
cache = bundle;
})
.pipe(source('runtime.js', './app/js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist'));
});
gulp.task('copy', function() {
gulp.src(['./app/*.html', './app/**/*.css'])
.pipe(gulp.dest('./dist/'));
});
gulp.task('html', function () {
gulp.src('./app/*.html')
.pipe(connect.reload());
});
gulp.task('watch', function () {
gulp.watch(
['./app/*.html', './app/css/*.css', './app/js/**/**.js'],
['rollup', 'html', 'copy']);
});
gulp.task('connect', function() {
connect.server({
root: 'app',
livereload: true,
middleware: function(app, opts) {
return require('./middleware');
}
});
});