2013-04-20 00:24:38 +00:00
|
|
|
module.exports = function (grunt) {
|
|
|
|
grunt.loadNpmTasks('grunt-typescript');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-copy');
|
2013-04-26 14:35:32 +00:00
|
|
|
|
2013-05-02 16:54:29 +00:00
|
|
|
var wrapPhaserInUmd = function(content, isAddon) {
|
|
|
|
var replacement = [
|
|
|
|
'(function (root, factory) {',
|
|
|
|
' if (typeof exports === \'object\') {',
|
|
|
|
' module.exports = factory();',
|
|
|
|
' } else if (typeof define === \'function\' && define.amd) {',
|
|
|
|
' define(factory);',
|
|
|
|
' } else {',
|
|
|
|
' root.Phaser = factory();',
|
|
|
|
' }',
|
|
|
|
'}(this, function () {',
|
|
|
|
content,
|
|
|
|
'return Phaser;',
|
|
|
|
'}));'
|
|
|
|
];
|
|
|
|
return replacement.join('\n');
|
|
|
|
};
|
|
|
|
|
|
|
|
var wrapAddonInUmd = function(content) {
|
|
|
|
var replacement = [
|
|
|
|
'(function (root, factory) {',
|
|
|
|
' if (typeof exports === \'object\') {',
|
|
|
|
' module.exports = factory(require(\'phaser\'));',
|
|
|
|
' } else if (typeof define === \'function\' && define.amd) {',
|
|
|
|
' define([\'phaser\'], factory);',
|
|
|
|
' } else {',
|
|
|
|
' factory(root.Phaser);',
|
|
|
|
' }',
|
|
|
|
'}(this, function (Phaser) {',
|
|
|
|
content,
|
|
|
|
'return Phaser;',
|
|
|
|
'}));'
|
|
|
|
];
|
|
|
|
return replacement.join('\n');
|
|
|
|
};
|
|
|
|
|
2013-04-20 00:24:38 +00:00
|
|
|
grunt.initConfig({
|
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
typescript: {
|
|
|
|
base: {
|
|
|
|
src: ['Phaser/**/*.ts'],
|
|
|
|
dest: 'build/phaser.js',
|
|
|
|
options: {
|
2013-05-02 16:54:29 +00:00
|
|
|
target: 'ES5',
|
|
|
|
declaration: true,
|
|
|
|
comments: true
|
|
|
|
}
|
|
|
|
},
|
2013-06-26 13:18:48 +00:00
|
|
|
//tests: {
|
|
|
|
// src: ['Tests/**/*.ts'],
|
|
|
|
// options: {
|
|
|
|
// target: 'ES5',
|
|
|
|
// declaration: true,
|
|
|
|
// comments: true
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//fx: {
|
|
|
|
// src: ['SpecialFX/**/*.ts'],
|
|
|
|
// dest: 'build/phaser-fx.js',
|
|
|
|
// options: {
|
|
|
|
// target: 'ES5',
|
|
|
|
// declaration: true,
|
|
|
|
// comments: true
|
|
|
|
// }
|
|
|
|
//}
|
2013-05-02 16:54:29 +00:00
|
|
|
},
|
|
|
|
copy: {
|
|
|
|
main: {
|
|
|
|
files: [{
|
|
|
|
src: 'build/phaser.js',
|
|
|
|
dest: 'Tests/phaser.js'
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
fx: {
|
|
|
|
files: [{
|
|
|
|
src: 'build/phaser-fx.js',
|
|
|
|
dest: 'Tests/phaser-fx.js'
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
mainAmd: {
|
|
|
|
files: [{
|
|
|
|
src: 'build/phaser.js',
|
|
|
|
dest: 'build/phaser.amd.js'
|
|
|
|
}],
|
|
|
|
options: {
|
|
|
|
processContent: wrapPhaserInUmd
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fxAmd: {
|
|
|
|
files: [{
|
|
|
|
src: 'build/phaser-fx.js',
|
|
|
|
dest: 'build/phaser-fx.amd.js'
|
|
|
|
}],
|
|
|
|
options: {
|
|
|
|
processContent: wrapAddonInUmd
|
2013-04-20 00:24:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2013-05-02 16:54:29 +00:00
|
|
|
watch: {
|
2013-04-20 00:24:38 +00:00
|
|
|
files: '**/*.ts',
|
|
|
|
tasks: ['typescript', 'copy']
|
|
|
|
}
|
|
|
|
});
|
2013-04-26 14:35:32 +00:00
|
|
|
|
2013-05-02 16:54:29 +00:00
|
|
|
grunt.registerTask('default', ['typescript', 'copy', 'watch']);
|
2013-04-26 14:35:32 +00:00
|
|
|
|
2013-04-20 00:24:38 +00:00
|
|
|
}
|