diff --git a/build/client.js b/build/client.js
index fbf53f8..04baa9d 100755
--- a/build/client.js
+++ b/build/client.js
@@ -1,10 +1,15 @@
const gulp = require('gulp');
+const concat = require('gulp-concat');
+const uglify = require('gulp-uglify');
+const babel = require('gulp-babel');
+const template = require('gulp-template');
const yargs = require('yargs');
const Haxe = require('../tasks/haxe');
const FlashPlayer = require('../tasks/flashplayer');
const version = require('./version');
const prepare = require('./prepare');
const debug = require('../tasks/debug');
+const webserver = require('gulp-webserver');
const generate = () => function generate() {
@@ -13,26 +18,67 @@ const generate = () => function generate() {
]);
};
-const build = () => function build() {
+const build = (platform) => function build() {
const argv = yargs.argv;
return gulp.src('.')
.pipe(new Haxe().openfl({
command: 'build',
- platform: 'flash',
+ platform: platform,
version: version,
- outputFile: 'tankz.swf',
debug: argv.dev,
}))
- .pipe(gulp.dest('target'));
+ .pipe(gulp.dest(`target/${platform}`));
};
-const test = (build) => function test() {
+const flashIndex = function() {
+ return gulp.src('src/client/html/index.html')
+ .pipe(template({
+ scripts: ['app.min.js'],
+ swf: 'tankz.swf'
+ }))
+ .pipe(gulp.dest('target/flash'))
+};
+
+const flashJs = function() {
+ const src = [
+ 'src/client/html/js/*.js'
+ ];
+ return gulp.src(src)
+ .pipe(babel({presets: ['es2015']}))
+ .pipe(uglify())
+ .pipe(concat('app.min.js'))
+ .pipe(gulp.dest('target/flash'))
+};
+
+const webapp = function () {
+ return gulp.src('src/webapp/*').pipe(gulp.dest('target'));
+};
+
+exports['client:flash:html'] = gulp.parallel(flashIndex, flashJs);
+exports['client:flash'] = gulp.series(prepare(Haxe.ID), generate(), build('flash'), exports['client:flash:html']);
+exports['client:html5'] = gulp.series(prepare(Haxe.ID), generate(), build('html5'));
+exports['client:webapp'] = webapp;
+exports['client'] = gulp.series(prepare(Haxe.ID), generate(), gulp.parallel(build('flash'), build('html5')), exports['client:flash:html'], webapp);
+
+
+
+const testFlash = function() {
const argv = yargs.argv;
- return build()
- .pipe(new FlashPlayer().run(argv.dev))
- .pipe(debug());
+ return build('flash')
+ .pipe(new FlashPlayer().run(argv.dev))
+ .pipe(debug());
};
+const testHtml5 = function() {
+ return gulp.series(build('html5'), () => gulp.src('target/html5').pipe(webserver({
+ host: 'localhost', port: 3000,
+ open: true,
+ fallback: 'index.html'
+ })))();
+};
+
+exports['client:flash:test'] = gulp.series(prepare(Haxe.ID, FlashPlayer.ID), testFlash);
+exports['client:html5:test'] = gulp.series(prepare(Haxe.ID), testHtml5);
+exports['client:test'] = exports['client:flash:test'];
+
-exports['client'] = gulp.series(prepare(Haxe.ID), generate(), build());
-exports['client:test'] = gulp.series(prepare(Haxe.ID, FlashPlayer.ID), test(build()));
diff --git a/build/webapp.js b/build/webapp.js
index 4e88e61..e69de29 100644
--- a/build/webapp.js
+++ b/build/webapp.js
@@ -1,28 +0,0 @@
-const gulp = require('gulp');
-const concat = require('gulp-concat');
-const uglify = require('gulp-uglify');
-const babel = require('gulp-babel');
-const template = require('gulp-template');
-
-
-const index = () => function index() {
- return gulp.src('src/webapp/index.html')
- .pipe(template({
- scripts: ['app.min.js'],
- swf: 'tankz.swf'
- }))
- .pipe(gulp.dest('target'))
-};
-
-const js = () => function js() {
- const src = [
- 'src/webapp/js/*.js'
- ];
- return gulp.src(src)
- .pipe(babel({presets: ['es2015']}))
- .pipe(uglify())
- .pipe(concat('app.min.js'))
- .pipe(gulp.dest('target'))
-};
-
-exports['webapp'] = gulp.parallel(index(), js());
\ No newline at end of file
diff --git a/gulpfile.js b/gulpfile.js
index 8dc33bd..e06e65f 100755
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -30,6 +30,6 @@ exports.update = prepare.update;
merge('./build/prepare');
merge('./build/client');
merge('./build/server');
-merge('./build/webapp');
-exports.default = gulp.series(exports.clean, exports.client, exports.webapp);
\ No newline at end of file
+
+exports.default = gulp.series(exports.clean, exports.client);
\ No newline at end of file
diff --git a/package.json b/package.json
index 38f50b8..5bc7d1e 100755
--- a/package.json
+++ b/package.json
@@ -17,12 +17,14 @@
"gulp-concat": "^2.6.1",
"gulp-template": "^5.0.0",
"gulp-uglify": "^3.0.0",
+ "gulp-webserver": "^0.9.1",
"plugin-error": "^0.1.2",
"progress": "^2.0.0",
"promise-streams": "^2.1.1",
"tar": "^4.2.0",
"tmp-file": "^2.0.1",
"unzip-stream": "^0.2.1",
+ "vinyl-fs": "^3.0.1",
"yargs": "^10.0.3"
}
}
diff --git a/project.xml b/project.xml
index ef388b1..8f89b5c 100755
--- a/project.xml
+++ b/project.xml
@@ -9,7 +9,7 @@