-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
53 lines (44 loc) · 1.28 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
var gulp = require('gulp');
var amdOptimizer = require('gulp-amd-optimizer');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var del = require('del');
var replace = require('gulp-replace');
var requireConfig = {
baseUrl: 'src'
};
var options = {
umd: false
};
var timestamp = (new Date().valueOf() + '').slice(0, -3);
gulp.task('index', function () {
return gulp.src('dist/index.php')
.pipe(replace(/(game\.js\?v=)\d+/g, '$1' + timestamp))
.pipe(gulp.dest('dist'));
});
gulp.task('script:src', function () {
return gulp.src('src/**/*.js', {base: requireConfig.baseUrl})
.pipe(replace(/\*TIMESTAMP\*/g, timestamp))
.pipe(amdOptimizer(requireConfig, options))
.pipe(concat('game.js'))
.pipe(uglify({mangle: false}))
.pipe(gulp.dest('dist/asset'));
});
gulp.task('script:dep', function () {
return gulp.src('dep/*.js')
.pipe(gulp.dest('dist/dep'));
});
gulp.task('clean:image', function () {
del.sync(['dist/asset/img']);
});
gulp.task('image', function () {
return gulp.src(['src/img/**/*.png', '!src/img/psd', '!src/img/psd/**/*'])
.pipe(gulp.dest('dist/asset/img'));
});
gulp.task('default', [
'index',
'script:dep',
'script:src',
'clean:image',
'image'
]);