-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
54 lines (44 loc) · 1.25 KB
/
Copy pathgulpfile.js
File metadata and controls
54 lines (44 loc) · 1.25 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
const gulp = require('gulp');
const gutil = require('gulp-util');
const deploy = require('gulp-gh-pages');
const babel = require('babelify');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const browserSync = require('browser-sync');
const PHASER = './node_modules/phaser/build/phaser.min.js';
gulp.task('phaser', () => {
return gulp.src(PHASER)
.pipe(gulp.dest('build/vendor'));
});
gulp.task('static', ['phaser'], () => {
return gulp.src('static/**/*')
.pipe(gulp.dest('build'));
});
gulp.task('deploy', ['build'], () => {
return gulp.src('build/**/*')
.pipe(deploy());
});
gulp.task('babel', () => {
const bundler = browserify('src/main.js');
return bundler
.transform(babel, { presets: ['es2015'] })
.bundle()
.on('error', gutil.log)
.pipe(source('main.js'))
.pipe(buffer())
.pipe(gulp.dest('build'));
});
gulp.task('dev', () => {
const options = {
server: {
baseDir: 'build',
},
open: true,
};
browserSync(options);
gulp.watch('src/**/*.js', ['babel', browserSync.reload]);
gulp.watch('static/**/*', ['static', browserSync.reload]);
});
gulp.task('build', ['static', 'babel']);
gulp.task('default', ['build']);