-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
83 lines (73 loc) · 2.21 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
var gulp = require('gulp');
var typescript = require('gulp-typescript');
var concat = require('gulp-concat');
var browserSync = require("browser-sync");
var runSequence = require('run-sequence');
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');
var rimraf = require('rimraf');
var uglify = require('gulp-uglify');
browserSync({
server: {
baseDir: "build"
}
});
gulp.task('build-minify', function () {
gulp.src(['src/ts/**/*.ts'])
.pipe(typescript({
target: "ES5",
removeComments: true,
sortOutput: true
}))
.js
.pipe(concat("main.js"))
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(gulp.dest('build/js/'));
});
gulp.task('typescript-compile', function () {
gulp.src(['src/ts/**/*.ts'])
.pipe(typescript({
target: "ES5",
removeComments: false,
sortOutput: true
}))
.js
.pipe(concat("main.js"))
.pipe(gulp.dest('build/js/'));
});
gulp.task('clean', function (callback) {
rimraf('./build', callback);
});
gulp.task("clean-build", ['clean'], function () {
runSequence(
"build-minify",
"copy-all"
);
});
gulp.task('copy-all', ['copy-libs', 'copy-html', 'copy-css', 'copy-texture']);
gulp.task('copy-libs', function () {
gulp.src('src/libs/**/*.js').pipe(gulp.dest('build/js/'));
});
gulp.task('copy-html', function () {
gulp.src('src/index.html').pipe(gulp.dest('build/'));
});
gulp.task('copy-texture', function () {
gulp.src('src/texture/**/*.+(jpg|jpeg|png)').pipe(gulp.dest('build/texture/'));
});
gulp.task('copy-css', function () {
gulp.src('src/css/*.css').pipe(gulp.dest('build/css/'));
});
// browserSync-browserSync-reload
gulp.task("reload", function () {
browserSync.reload();
});
gulp.task("watch", ["reload"], function () {
gulp.watch(['src/libs/**/*.js'], ['copy-libs']);
gulp.watch(['src/index.html'], ['copy-html']);
gulp.watch(['src/texture/**/*.+(jpg|jpeg|png)'], ['copy-texture']);
gulp.watch(['src/css/*.*'], ['copy-css']);
gulp.watch(['src/ts/**/*.*'], ['typescript-compile']);
gulp.watch(['build/**/*.*'], ['reload']);
});