Skip to content

Commit f66e0e9

Browse files
HackManiacdanielwippermann
authored andcommitted
Automatic creation of UMD wrapped variant of Phaser
1 parent 2087b2d commit f66e0e9

1 file changed

Lines changed: 37 additions & 10 deletions

File tree

GruntFile.js

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = function (grunt) {
22
grunt.loadNpmTasks('grunt-typescript');
33
grunt.loadNpmTasks('grunt-contrib-watch');
44
grunt.loadNpmTasks('grunt-contrib-copy');
5-
5+
66
grunt.initConfig({
77
pkg: grunt.file.readJSON('package.json'),
88
typescript: {
@@ -14,18 +14,45 @@ module.exports = function (grunt) {
1414
}
1515
}
1616
},
17-
copy: {
18-
main: {
19-
files: [
20-
{src: 'build/phaser.js', dest: 'Tests/phaser.js'}
21-
]}
22-
},
23-
watch: {
17+
copy: {
18+
main: {
19+
files: [{
20+
src: 'build/phaser.js',
21+
dest: 'Tests/phaser.js'
22+
}]
23+
},
24+
amd: {
25+
files: [{
26+
src: 'build/phaser.js',
27+
dest: 'build/phaser.amd.js'
28+
}],
29+
options: {
30+
processContent: function(content) {
31+
var replacement = [
32+
'(function (root, factory) {',
33+
' if (typeof exports === \'object\') {',
34+
' module.exports = factory();',
35+
' } else if (typeof define === \'function\' && define.amd) {',
36+
' define(factory);',
37+
' } else {',
38+
' root.Phaser = factory();',
39+
' }',
40+
'}(this, function () {',
41+
content,
42+
'return Phaser;',
43+
'}));'
44+
];
45+
return replacement.join('\n');
46+
}
47+
}
48+
}
49+
},
50+
watch: {
2451
files: '**/*.ts',
2552
tasks: ['typescript', 'copy']
2653
}
2754
});
28-
55+
2956
grunt.registerTask('default', ['watch']);
30-
57+
3158
}

0 commit comments

Comments
 (0)