-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (58 loc) · 3.5 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
var gulp = require('gulp');
var ts = require('gulp-typescript');
var flatten = require('gulp-flatten');
var less = require('gulp-less');
var merge = require('merge2');
var electron = require('gulp-electron');
var sourcemaps = require('gulp-sourcemaps');
var del = require('del');
var hudProject = ts.createProject('src-hud/tsconfig.json');
var dexNavProject = ts.createProject('src-dexnav/tsconfig.json');
var srvProject = ts.createProject('src-server/tsconfig.json');
var appProject = ts.createProject('src-app/tsconfig.json');
gulp.task('clean-old-release', () => del('release/'));
gulp.task('copy-ini', () => gulp.src('./*.ini').pipe(gulp.dest('bin/')));
gulp.task('copy-data', () => gulp.src('./src-server/data/**/*').pipe(gulp.dest('bin/data/')));
gulp.task('copy-fonts', () => gulp.src('./styles/fonts/*').pipe(gulp.dest('bin/fonts/')));
gulp.task('copy-html', () => gulp.src('./src*/*.html').pipe(flatten()).pipe(gulp.dest('bin/')));
gulp.task('copy-img', () => gulp.src('./img/**/*').pipe(gulp.dest('bin/img/')));
gulp.task('copy-package', () => gulp.src('./package.json').pipe(gulp.dest('bin/')));
gulp.task('copy-node-packages', () => gulp.src('./node_modules/ini/**/*').pipe(gulp.dest('bin/node_modules/ini/')));
gulp.task('copy-deps', gulp.series('copy-node-packages', () => gulp.src('./node_modules/react*/dist/*.js').pipe(flatten()).pipe(gulp.dest('bin/lib/'))));
gulp.task('compile-less', gulp.series('copy-fonts', () => gulp.src('./styles/*.less').pipe(sourcemaps.init()).pipe(less()).pipe(sourcemaps.write()).pipe(gulp.dest('bin/'))));
gulp.task('copy-config', gulp.series('copy-ini', () => gulp.src('./config.json').pipe(gulp.dest('bin/'))));
gulp.task('build-backend', () => {
let ts = srvProject.src().pipe(sourcemaps.init()).pipe(srvProject());
return merge(
ts.js.pipe(sourcemaps.write()).pipe(gulp.dest("bin/")),
ts.dts.pipe(gulp.dest("ref/"))
);
});
gulp.task('build-hud', gulp.series('build-backend', () => hudProject.src().pipe(sourcemaps.init()).pipe(hudProject()).js.pipe(sourcemaps.write()).pipe(gulp.dest("bin/"))));
gulp.task('build-dexnav', gulp.series('build-backend', () => dexNavProject.src().pipe(sourcemaps.init()).pipe(dexNavProject()).js.pipe(sourcemaps.write()).pipe(gulp.dest("bin/"))));
gulp.task('build-frontend', gulp.series('build-backend', 'build-hud', 'build-dexnav', 'copy-html', 'copy-data', 'compile-less', 'copy-img'));
gulp.task('build-app', gulp.series('build-frontend', 'copy-config', 'copy-deps', 'copy-package', () => appProject.src().pipe(appProject()).js.pipe(gulp.dest("bin/"))));
gulp.task('package-app', gulp.series('clean-old-release', 'build-app', () => {
var packageJson = require('./bin/package.json');
return gulp.src("./")
.pipe(electron({
src: './bin',
packageJson: packageJson,
release: './release',
cache: './cache',
version: 'v5.0.2',
packaging: false,
// token: 'abc123...',
platforms: ['win32-x64'],
platformResources: {
win: {
"version-string": packageJson.version,
"file-version": packageJson.version,
"product-version": packageJson.version,
"icon": './img/pokemon.ico' //icon from http://www.iconspedia.com/icon/pokemon-icon-44128.html
}
}
}))
.pipe(gulp.dest("./"));
}));
gulp.task('build', gulp.series('package-app'));