-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
66 lines (61 loc) · 1.76 KB
/
Copy pathgulpfile.js
File metadata and controls
66 lines (61 loc) · 1.76 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const gulp = require('gulp');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const watchify = require('watchify');
const tsify = require('tsify');
const gutil = require('gulp-util');
const paths = {
pages: ['src/*.html', 'src/*.js', 'src/images/*'],
};
const watchedBrowserify = watchify(
browserify({
basedir: '.',
debug: true,
entries: [
'src/dayDisplayCorner.ts',
'src/controlButton.ts',
'src/energyIndicatorView.ts',
'src/event.ts',
'src/feedback.ts',
'src/graph.ts',
'src/lightSwitch.ts',
'src/lightSwitch3.ts',
'src/lightSwitch5.ts',
'src/main.ts',
'src/plantGlucoseSimulation.ts',
'src/plantAnimationCorner.ts',
'src/playPauseButton.ts',
'src/resetButton.ts',
'src/simulationEndFeedback.ts',
'src/simulationSpeedSwitch.ts',
'src/simulationState.ts',
'src/util.ts',
'src/wiseAPI.ts',
],
cache: {},
packageCache: {},
}).plugin(tsify)
);
gulp.task('copy-resources', function () {
return gulp.src(paths.pages, { base: './src/' }).pipe(gulp.dest('dist'));
});
gulp.task('copy-changes', function () {
return gulp.watch(paths.pages, function (obj) {
if (obj.type === 'changed' || obj.type === 'added') {
console.log('copying changed file: ' + obj.path + ' to dist folder');
gulp.src(obj.path, { base: './src/' }).pipe(gulp.dest('./dist'));
}
});
});
function bundle() {
return watchedBrowserify
.bundle()
.on('error', function (err) {
console.log(err);
})
.pipe(source('bundle.js'))
.pipe(gulp.dest('dist'));
}
gulp.task('default', ['copy-resources', 'copy-changes'], bundle);
watchedBrowserify.on('update', bundle);
watchedBrowserify.on('log', gutil.log);