From 32434811b93887d8d6220d03dafee08b38adfc0d Mon Sep 17 00:00:00 2001 From: Oreolek Date: Tue, 8 Dec 2015 14:57:24 +0700 Subject: [PATCH] Gulp concatenation --- Gulpfile.js | 29 ++++++++++++++++++++--------- game/00begin.coffee | 19 +++++++++++++++++++ game/{main.coffee => 99end.coffee} | 23 ----------------------- game/{ => translations}/en.coffee | 0 game/{ => translations}/ru.coffee | 0 package.json | 1 + 6 files changed, 40 insertions(+), 32 deletions(-) create mode 100644 game/00begin.coffee rename game/{main.coffee => 99end.coffee} (54%) rename game/{ => translations}/en.coffee (100%) rename game/{ => translations}/ru.coffee (100%) diff --git a/Gulpfile.js b/Gulpfile.js index e508469..02e90d9 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -1,8 +1,5 @@ 'use strict'; -/* Raconteur Gulpfile scaffold. */ -/* Includes code adapted from Gulp documentation, among other sources. */ - /* Imports */ var watchify = require('watchify'), browserify = require('browserify'), @@ -16,7 +13,8 @@ var watchify = require('watchify'), uglify = require('gulp-uglify'), buffer = require('vinyl-buffer'), zip = require('gulp-zip'), - _ = require('lodash'); + _ = require('lodash'), + concat = require('gulp-concat'); var reload = browserSync.reload; @@ -69,7 +67,7 @@ gulp.task('buildUndum', function () { /* Generate JavaScript with browser sync. */ var customOpts = { - entries: ['./game/main.coffee'], + entries: ['./build/game/main.coffee'], debug: true, transform: [coffeify] }; @@ -78,10 +76,6 @@ var opts = _.assign({}, watchify.args, customOpts); var bundler = watchify(browserify(opts)); bundler.external('undum-commonjs'); -gulp.task('coffee', ['buildUndum'], bundle); // `gulp coffee` will generate bundle -bundler.on('update', bundle); // Re-bundle on dep updates -bundler.on('log', gutil.log); // Output build logs to terminal - function bundle () { return bundler.bundle() .on('error', gutil.log.bind(gutil, 'Browserify Error')) @@ -89,6 +83,23 @@ function bundle () { .pipe(gulp.dest('./build/game')); }; +gulp.task('copyTranslations', [], function() { + gulp.src('./game/translations/*.coffee') + .pipe(gulp.dest('./build/game/translations')); +}); + +gulp.task('concatCoffee', ['copyTranslations'], function() { + return gulp.src('./game/*.coffee') + .pipe(concat('./main.coffee')) + .pipe(gulp.dest('./build/game')); +}); + +// `gulp coffee` will generate bundle +gulp.task('coffee', ['buildUndum', 'concatCoffee'], bundle); + +bundler.on('update', bundle); // Re-bundle on dep updates +bundler.on('log', gutil.log); // Output build logs to terminal + /* Make a development build */ gulp.task('build', ['html', 'img', 'less', 'coffee', 'audio'], function () { diff --git a/game/00begin.coffee b/game/00begin.coffee new file mode 100644 index 0000000..ed23446 --- /dev/null +++ b/game/00begin.coffee @@ -0,0 +1,19 @@ +# copyright (c) Alexander Yakovlev 2015. +# This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. +# To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0 + +situation = require('raconteur') +undum = require('undum-commonjs') +oneOf = require('raconteur/lib/oneOf.js') +qualities = require('raconteur/lib/qualities.js') + +undumloc = require("./translations/ru.coffee").language +undum.language["ru"] = undumloc +undumloc = require("./translations/en.coffee").language +undum.language["en"] = undumloc +$ = require("jquery") +Array.prototype.oneOf = () -> + oneOf.apply(null, this) + +undum.game.id = "7a1aba32-f0fd-4e3b-ba5a-59e3fa9e6012" +undum.game.version = "2.0" diff --git a/game/main.coffee b/game/99end.coffee similarity index 54% rename from game/main.coffee rename to game/99end.coffee index 436d0ae..987fae8 100644 --- a/game/main.coffee +++ b/game/99end.coffee @@ -1,23 +1,3 @@ -# copyright (c) Alexander Yakovlev 2015. -# This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. -# To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0 - -situation = require('raconteur') -undum = require('undum-commonjs') -oneOf = require('raconteur/lib/oneOf.js') -qualities = require('raconteur/lib/qualities.js') - -undumloc = require("./ru.coffee").language -undum.language["ru"] = undumloc -undumloc = require("./en.coffee").language -undum.language["en"] = undumloc -$ = require("jquery") -Array.prototype.oneOf = () -> - oneOf.apply(null, this) - -undum.game.id = "7a1aba32-f0fd-4e3b-ba5a-59e3fa9e6012" -undum.game.version = "2.0" - qualities head: bullets: qualities.integer("bullets".l()), @@ -46,7 +26,4 @@ undum.game.init = (character, system) -> # console.log( 'Character object:', character ) #, 1000 ); -require("./gameplay.coffee") -require("./story.coffee") - window.onload = undum.begin diff --git a/game/en.coffee b/game/translations/en.coffee similarity index 100% rename from game/en.coffee rename to game/translations/en.coffee diff --git a/game/ru.coffee b/game/translations/ru.coffee similarity index 100% rename from game/ru.coffee rename to game/translations/ru.coffee diff --git a/package.json b/package.json index f3559f1..bfbeea0 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "gulp-uglify": "^1.2.0", "gulp-util": "^3.0.4", "gulp-zip": "^3.0.2", + "gulp-concat": "^2.6.0", "lodash": "^3.6.0", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0",