Skip to content

Commit

Permalink
Added version replace grunt task - issue #9
Browse files Browse the repository at this point in the history
  • Loading branch information
petarov committed Feb 10, 2014
1 parent 6d919f0 commit 8f515fd
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 4 deletions.
25 changes: 23 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ module.exports = function(grunt) {
dest: 'build/<%= pkg.name %>-<%= pkg.version %>.js'
}
},

replace: {
dist: {
options: {
patterns: [
{
match: 'VERSION',
replacement: '<%= pkg.version %>',
expression: false // simple variable lookup
}
]
},
files: [
{expand: true, flatten: true, src: ['build/index.html'], dest: 'build/'}
]
}
},

/**
* Rules of how to minify & obfuscate game sources
*/
Expand Down Expand Up @@ -65,6 +83,9 @@ module.exports = function(grunt) {
clean: {
dist: [
'build/*'
],
concat: [
'<%= concat.dist.dest %>'
]
},
/**
Expand All @@ -89,9 +110,9 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
// grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-replace');

// Default task.
grunt.registerTask('default', ['concat', 'uglify', 'copy']);
grunt.registerTask('default', ['concat', 'uglify', 'copy', 'replace', 'clean:concat']);
grunt.registerTask('lint', ['jshint:beforeConcat']);
};
79 changes: 79 additions & 0 deletions index-dev.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>Psiral - Javascript/HTML5 game (Game-Off 2013)</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/main.css">
</head>
<body>

<!-- Canvas placeholder -->
<div id="screen">
<div id="top"></div>
</div>
<div id="bottom"></div>

<!-- Versioning -->
<script type="text/javascript">
var _timestamp = (new Date()).getTime();
var _version = {
buildnumber:_timestamp,
};
</script>
<!-- Libraries -->
<script src="vendor/underscore-min.js"></script>
<script src="vendor/howler.min.js"></script>
<script src="vendor/melonJS-0.9.11.js"></script>
<script src="vendor/plugins/debugPanel.js"></script>
<script src="vendor/plugins/fndelay.js"></script>
<script src="vendor/plugins/howlerAudio.js"></script>
<!-- Game -->
<script src="js/globals.js"></script>
<script src="js/game.js"></script>
<script src="js/resources.js"></script>
<script src="js/map.js"></script>
<script src="js/gamemaster.js"></script>
<script src="js/l10n.js"></script>
<!-- Scenes -->
<script src="js/scenes/splash.js"></script>
<script src="js/scenes/menu.js"></script>
<script src="js/scenes/menu_hud.js"></script>
<script src="js/scenes/play.js"></script>
<script src="js/scenes/play_hud.js"></script>
<!-- Objects -->
<script src="js/entities/wizards.js"></script>
<script src="js/entities/board.js"></script>
<script src="js/entities/gfx.js"></script>
<!-- Bootstrap & Mobile optimization tricks -->
<script type="text/javascript">
window.onReady(function onReady() {
game.onload();

// Mobile browser hacks
if (me.device.isMobile && !navigator.isCocoonJS) {
// Prevent the webview from moving on a swipe
window.document.addEventListener("touchmove", function (e) {
e.preventDefault();
window.scroll(0, 0);
return false;
}, false);

// Scroll away mobile GUI
(function () {
window.scrollTo(0, 1);
me.video.onresize(null);
}).defer();

me.event.subscribe(me.event.WINDOW_ONRESIZE, function (e) {
window.scrollTo(0, 1);
});
}
});
</script>
<!--URCHIN-->
</body>
</html>
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<script type="text/javascript">
var _timestamp = (new Date()).getTime();
var _version = {
buildnumber:_timestamp,
buildnumber:'@@VERSION',
};
</script>
<!-- Libraries -->
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"grunt-contrib-uglify": "~0.3.2",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-copy": "~0.5.0"
"grunt-contrib-copy": "~0.5.0",
"grunt-replace": "~0.6.1"
},
"engines": {
"node": ">=0.8"
Expand Down

0 comments on commit 8f515fd

Please sign in to comment.