-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (65 loc) · 1.59 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
'use strict';
var _ = require('lodash');
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var buble = require('gulp-buble');
var notify = require('gulp-notify');
var connect = require('gulp-connect');
/**
* Error function for plumber
* @param {Object} error
*/
var onError = notify.onError('Ошибка в <%= error.plugin %>');
var paths = {};
paths.srcBase = 'src';
paths.src = {};
paths.src.scriptsBase = paths.srcBase + '/scripts';
paths.src.scripts = paths.src.scriptsBase + '/*.js';
paths.buildBase = 'dist';
paths.build = {};
paths.build.scripts = paths.buildBase + '/scripts';
//copy libs from node modules
gulp.task('copy-assets', function() {
var assets = {
js: [
'./node_modules/phaser/build/phaser.min.js'
]
};
_(assets).forEach(function(assets, type) {
gulp.src(assets).pipe(gulp.dest(paths.build.scripts + '/lib/' + type));
});
});
//run a webserver
gulp.task('connect', function(){
connect.server({
root: ['dist'],
port: 8080,
base: 'http://localhost',
livereload: true
});
});
//ES6 to ES5
gulp.task('buble', function() {
return gulp.src(paths.src.scripts)
.pipe(plumber({
errorHandler: onError
}))
.pipe(buble())
.pipe(plumber.stop())
.pipe(gulp.dest(paths.build.scripts))
.pipe(connect.reload());
});
//JS task
gulp.task('js', [
'buble'
]);
//Build task
gulp.task('build', [
'js'
]);
//Watch task
gulp.task('watch', function () {
gulp.watch(paths.src.scripts, ['js']);
});
// Run
gulp.task('default', ['connect', 'watch']);