Skip to content

Commit e9cc510

Browse files
committed
WiP: playing with gulp
1 parent 724ec50 commit e9cc510

5 files changed

Lines changed: 60 additions & 8 deletions

File tree

gulpfile.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
var gulp = require('gulp');
1+
var gulp = require('gulp');
2+
var requireDir = require("require-dir-all");
3+
4+
requireDir("./samples", {recursive: true, includeFiles: /^gulpfile.js$/});
25

36
gulp.task('default', function() {});

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"description": "Framework to create javascript games",
55
"main": "index.js",
66
"scripts": {
7-
"build": "rm -rf build || true; npm run create_brickbreaker_levels; mkdir -p build; cp samples/*.html build; for js in samples/*.js; do browserify -t brfs $js > $(echo $js | perl -pe 's{^samples}{build}'); done",
8-
"brickbreaker": "npm install && gulp brickbreaker:levels && cd samples/brickbreaker && budo brickbreaker.js --open --live --debug -- -t brfs -t require-globify"
7+
"build": "npm install && gulp brickbreaker:build",
8+
"brickbreaker": "npm install && gulp brickbreaker"
99
},
1010
"repository": {
1111
"type": "git",
@@ -21,10 +21,11 @@
2121
"browserify": "^13.0.0",
2222
"budo": "^8.2.1",
2323
"gulp": "^3.9.1",
24+
"gulp-browserify2": "0.0.2",
2425
"gulp-concat": "^2.6.0",
2526
"gulp-insert": "^0.5.0",
26-
"gulp-replace": "^0.5.4",
2727
"gulp-minify": "^0.0.10",
28+
"gulp-replace": "^0.5.4",
2829
"gulp-util": "^3.0.7"
2930
},
3031
"dependencies": {

samples/brickbreaker/gulpfile.js

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
var gulp = require('gulp');
2-
var concat = require('gulp-concat');
3-
var insert = require('gulp-insert');
4-
var replace = require('gulp-replace');
1+
var gulp = require('gulp');
2+
var concat = require('gulp-concat');
3+
var insert = require('gulp-insert');
4+
var replace = require('gulp-replace');
5+
var browserify = require("gulp-browserify2");
6+
var inject = require('gulp-inject');
7+
var webserver = require('gulp-webserver');
58

69
gulp.task('default', function() {});
710

@@ -14,3 +17,39 @@ gulp.task('brickbreaker:levels', function() {
1417
.pipe(insert.wrap('module.exports = [', '];'))
1518
.pipe(gulp.dest(levelsPath));
1619
});
20+
21+
gulp.task('brickbreaker:build', ["brickbreaker:levels"], function() {
22+
var js = gulp
23+
.src("samples/brickbreaker/index.js")
24+
.pipe(browserify({
25+
fileName: "brickbreaker.js",
26+
transform: [require("brfs"), require("require-globify")],
27+
options: {
28+
debug: true
29+
}
30+
}))
31+
.pipe(gulp.dest("build"))
32+
;
33+
34+
gulp
35+
.src("samples/brickbreaker/*.html")
36+
.pipe(gulp.dest("build"))
37+
.pipe(inject(js, {relative: true}))
38+
.pipe(gulp.dest("build"))
39+
;
40+
});
41+
42+
gulp.task("brickbreaker:watch", ["brickbreaker:build"], function() {
43+
gulp.watch(["index.js", "screen.js", "elements/**.js", "samples/brickbreaker/**.js", "samples/brickbreaker/**.lvl", "**.json"], ['brickbreaker:build']);
44+
});
45+
46+
gulp.task("brickbreaker", ["brickbreaker:watch"], function() {
47+
gulp
48+
.src("build/")
49+
.pipe(webserver({
50+
livereload: true,
51+
directoryListing: false,
52+
open: true
53+
}))
54+
;
55+
});

samples/brickbreaker/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html>
2+
<head>
3+
</head>
4+
<body>
5+
<!-- inject:js -->
6+
<script src="build/brickbreaker.js"></script>
7+
<!-- endinject -->
8+
</body>
9+
</html>

0 commit comments

Comments
 (0)