mirror of
https://github.com/wassname/phaser.git
synced 2026-08-11 05:49:23 +08:00
Automatic creation of UMD wrapped variant of Phaser
This commit is contained in:
committed by
Daniel Wippermann
parent
2087b2d76e
commit
f66e0e9254
+37
-10
@@ -2,7 +2,7 @@ module.exports = function (grunt) {
|
||||
grunt.loadNpmTasks('grunt-typescript');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
typescript: {
|
||||
@@ -14,18 +14,45 @@ module.exports = function (grunt) {
|
||||
}
|
||||
}
|
||||
},
|
||||
copy: {
|
||||
main: {
|
||||
files: [
|
||||
{src: 'build/phaser.js', dest: 'Tests/phaser.js'}
|
||||
]}
|
||||
},
|
||||
watch: {
|
||||
copy: {
|
||||
main: {
|
||||
files: [{
|
||||
src: 'build/phaser.js',
|
||||
dest: 'Tests/phaser.js'
|
||||
}]
|
||||
},
|
||||
amd: {
|
||||
files: [{
|
||||
src: 'build/phaser.js',
|
||||
dest: 'build/phaser.amd.js'
|
||||
}],
|
||||
options: {
|
||||
processContent: function(content) {
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
files: '**/*.ts',
|
||||
tasks: ['typescript', 'copy']
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
grunt.registerTask('default', ['watch']);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user