diff --git a/client/pug/game.pug b/client/pug/game.pug new file mode 100644 index 0000000..35eacb8 --- /dev/null +++ b/client/pug/game.pug @@ -0,0 +1,9 @@ +doctype html +html + head + title Crafty Things + link(rel='stylesheet', href='style.css') + script(src='/socket.io/socket.io.js') + script(src='lib.min.js') + script(src='game.min.js') + body diff --git a/client/scripts/10-conf.coffee b/client/scripts/game/10-conf.coffee similarity index 100% rename from client/scripts/10-conf.coffee rename to client/scripts/game/10-conf.coffee diff --git a/client/scripts/10-init-framework.coffee b/client/scripts/game/10-init-framework.coffee similarity index 100% rename from client/scripts/10-init-framework.coffee rename to client/scripts/game/10-init-framework.coffee diff --git a/client/scripts/20-comp-BigCard.coffee b/client/scripts/game/20-comp-BigCard.coffee similarity index 100% rename from client/scripts/20-comp-BigCard.coffee rename to client/scripts/game/20-comp-BigCard.coffee diff --git a/client/scripts/20-comp-Card.coffee b/client/scripts/game/20-comp-Card.coffee similarity index 100% rename from client/scripts/20-comp-Card.coffee rename to client/scripts/game/20-comp-Card.coffee diff --git a/client/scripts/20-comp-Playmat.coffee b/client/scripts/game/20-comp-Playmat.coffee similarity index 100% rename from client/scripts/20-comp-Playmat.coffee rename to client/scripts/game/20-comp-Playmat.coffee diff --git a/client/scripts/30-scene-Battle.coffee b/client/scripts/game/30-scene-Battle.coffee similarity index 100% rename from client/scripts/30-scene-Battle.coffee rename to client/scripts/game/30-scene-Battle.coffee diff --git a/client/scripts/40-test-entities.coffee b/client/scripts/game/40-test-entities.coffee similarity index 100% rename from client/scripts/40-test-entities.coffee rename to client/scripts/game/40-test-entities.coffee diff --git a/gulpfile.js b/gulpfile.js index fc9ac5a..f05c2ae 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,31 +1,22 @@ +var fs = require('fs'); +var path = require('path'); +var merge = require('merge-stream'); var gulp = require('gulp'); var sourcemaps = require('gulp-sourcemaps'); var coffee = require('gulp-coffee'); +var pug = require('gulp-pug'); var insert = require('gulp-insert'); var uglify = require('gulp-uglify-es').default; var concat = require('gulp-concat'); var paths = { - coffee: 'client/scripts/**/*.coffee', - lib: 'client/lib/**/*.js', - images: 'client/img/**/*', - dest: 'static', - maps: 'maps' + lib: 'client/lib/*.js', + coffee: 'client/scripts', + pug: 'client/pug/*.pug', + dest: 'static', + maps: 'maps' }; -gulp.task('coffee', function(){ - return gulp.src(paths.coffee) - .pipe(sourcemaps.init()) - .pipe(concat('app.min.js')) - .pipe(coffee({bare: true})) - .pipe(insert.transform(function(contents, file) { - return '$(function () {' + contents + '});'; - })) - .pipe(uglify()) - .pipe(sourcemaps.write(paths.maps)) - .pipe(gulp.dest(paths.dest)) -}); - gulp.task('lib', function(){ return gulp.src(paths.lib) .pipe(sourcemaps.init()) @@ -34,4 +25,36 @@ gulp.task('lib', function(){ .pipe(gulp.dest(paths.dest)) }); -gulp.task('default', [ 'coffee', 'lib' ]); +function getFolders(dir) { + return fs.readdirSync(dir) + .filter(function(file) { + return fs.statSync(path.join(dir, file)).isDirectory(); + }); +} + +gulp.task('coffee', function(){ + var folders = getFolders(paths.coffee); + + var tasks = folders.map(function(folder) { + return gulp.src(path.join(paths.coffee, folder, '/**/*.coffee')) + .pipe(sourcemaps.init()) + .pipe(concat(folder + '.min.js')) + .pipe(coffee({bare: true})) + .pipe(insert.transform(function(contents, file) { + return '$(function () {' + contents + '});'; + })) + .pipe(uglify()) + .pipe(sourcemaps.write(paths.maps)) + .pipe(gulp.dest(paths.dest)) + }); + + return merge(tasks); +}); + +gulp.task('pug', function(){ + return gulp.src(paths.pug) + .pipe(pug()) + .pipe(gulp.dest(paths.dest)) +}); + +gulp.task('default', [ 'lib', 'coffee', 'pug' ]); diff --git a/package.json b/package.json index f331e8e..996ae44 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,10 @@ "express": "^4.16.1", "helmet": "*", "socket.io": "^2.1.1", + "merge-stream": "*", "gulp": "*", "gulp-sourcemaps": "*", + "gulp-pug": "*", "gulp-coffee": "*", "gulp-insert": "*", "gulp-uglify-es": "*", diff --git a/static/index.html b/static/index.html deleted file mode 100644 index 9b7f452..0000000 --- a/static/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - Crafty Things - - - - - - - -