@@ -6,10 +6,14 @@ module.exports = function (grunt) {
66 loadConfig ( grunt , {
77 configPath : __dirname + '/tasks/options' ,
88 config : {
9+ target_dir : 'build' ,
910 release_dir : 'build' ,
11+ release_custom_dir : 'build/custom' ,
1012 compile_dir : 'dist' ,
1113 modules_dir : 'dist/modules' ,
1214 docs_dir : 'docs' ,
15+ sourcemap : false ,
16+ filename : 'phaser' ,
1317 filelist : [ ] ,
1418 banner : require ( 'fs' ) . readFileSync ( __dirname + '/tasks/banner.txt' , 'utf8' )
1519 }
@@ -19,6 +23,9 @@ module.exports = function (grunt) {
1923
2024 grunt . registerTask ( 'default' , [ 'build' ] ) ;
2125
26+ grunt . registerTask ( 'docs' , [ 'clean:docs' , 'pixidoc' , 'jsdoc:html' , 'replace:docs' , 'clean:out' ] ) ;
27+ grunt . registerTask ( 'tsdocs' , [ 'clean:out' , 'pixidoc' , 'gitclone:plugins' , 'jsdoc:json' , 'buildtsdoc:pixi' , 'buildtsdoc:phaser' , 'replace:phasertsdefheader' , 'clean:out' ] ) ;
28+
2229 grunt . registerTask ( 'custom' , 'Build a custom version of Phaser' , function ( arg ) {
2330
2431 var modules = {
@@ -59,24 +66,13 @@ module.exports = function (grunt) {
5966
6067 } ;
6168
62- var defaults = {
63-
64- 'all' : [ 'ninja' ] ,
65- 'minimal' : [ 'keyboard' , 'gamepad' , 'graphics' , 'text' , 'retrofont' , 'bitmapdata' , 'rendertexture' , 'tweens' , 'sound' , 'particles' , 'debug' , 'tilemaps' , 'arcade' , 'p2' , 'ninja' ] ,
66- 'nophysics' : [ 'ninja' , 'p2' , 'arcade' , 'tilemaps' , 'particles' ] ,
67- 'arcade' : [ 'ninja' , 'p2' ] ,
68- 'p2' : [ 'ninja' , 'arcade' , 'particles' ] ,
69- 'arcadeMobile' : [ 'ninja' , 'p2' , 'keyboard' , 'gamepad' ] ,
70-
71- } ;
72-
73- grunt . log . writeln ( "----------------------------" ) ;
74- grunt . log . writeln ( "Building Phaser " + grunt . config . get ( 'package.version' ) + '-custom' ) ;
75- grunt . log . writeln ( "----------------------------" ) ;
69+ grunt . log . writeln ( "---------------------" ) ;
70+ grunt . log . writeln ( "Building Phaser " + grunt . config . get ( 'package.version' ) ) ;
71+ grunt . log . writeln ( "---------------------" ) ;
7672
7773 if ( ! grunt . option ( 'exclude' ) )
7874 {
79- grunt . log . writeln ( "\nUse --exclude to select which of the following modules to exclude:\n" ) ;
75+ grunt . log . writeln ( "\nUse --exclude to select which modules to exclude:\n" ) ;
8076
8177 for ( var key in modules )
8278 {
@@ -86,14 +82,30 @@ module.exports = function (grunt) {
8682 }
8783 }
8884
89- grunt . log . writeln ( "\nFor example: --exclude p2,tilemap,retrofont\n" ) ;
85+ grunt . log . writeln ( "\nFor example: --exclude p2,tilemap,retrofont --filename phaser-custom \n" ) ;
9086
9187 grunt . log . writeln ( "Note that some modules have dependencies on others.\n" ) ;
9288
9389 grunt . fail . fatal ( "No build options were specified." ) ;
9490 }
9591 else
9692 {
93+ // Defaults
94+ grunt . config . set ( 'sourcemap' , false ) ;
95+ grunt . config . set ( 'filename' , 'phaser' ) ;
96+ grunt . config . set ( 'target_dir' , '<%= release_dir %>' ) ;
97+
98+ // Overrides
99+ if ( grunt . option ( 'filename' ) )
100+ {
101+ grunt . config . set ( 'filename' , grunt . option ( 'filename' ) ) ;
102+ }
103+
104+ if ( grunt . option ( 'sourcemap' ) )
105+ {
106+ grunt . config . set ( 'sourcemap' , grunt . option ( 'sourcemap' ) ) ;
107+ }
108+
97109 grunt . log . writeln ( "Excluding modules:\n" ) ;
98110
99111 var excludes = grunt . option ( 'exclude' ) . split ( ',' ) ;
@@ -133,8 +145,8 @@ module.exports = function (grunt) {
133145
134146 var filelist = [ ] ;
135147
136- // Clean the dist folder
137- var tasks = [ 'clean:dist ' ] ;
148+ // Clean the working folder
149+ var tasks = [ 'clean:build ' ] ;
138150
139151 for ( var key in modules )
140152 {
@@ -160,21 +172,77 @@ module.exports = function (grunt) {
160172
161173 tasks . push ( 'uglify:custom' ) ;
162174
163- grunt . task . run ( tasks ) ;
175+ if ( grunt . option ( 'copy' ) )
176+ {
177+ tasks . push ( 'copy:custom' ) ;
178+ }
179+ else if ( grunt . option ( 'copycustom' ) )
180+ {
181+ grunt . config . set ( 'target_dir' , '<%= release_custom_dir %>' ) ;
182+ tasks . push ( 'copy:custom' ) ;
183+ }
164184
165- // grunt.log.writeln("\nCustom build of Phaser available in dist/phaser-custom.js\n" );
185+ grunt . task . run ( tasks ) ;
166186
167187 }
168188
169189 } ) ;
170190
171- grunt . registerTask ( 'test' , [ 'clean:dist' , 'concat' , 'uglify' ] ) ;
191+ grunt . registerTask ( 'dist' , 'Build all Phaser versions' , function ( ) {
192+
193+ grunt . task . run ( 'clean:release' ) ;
194+ grunt . task . run ( 'full' ) ;
195+ grunt . task . run ( 'arcadephysics' ) ;
196+ grunt . task . run ( 'nophysics' ) ;
197+ grunt . task . run ( 'minimum' ) ;
198+
199+ } ) ;
200+
201+ grunt . registerTask ( 'full' , 'Phaser complete' , function ( ) {
172202
173- grunt . registerTask ( 'build' , [ 'clean:dist' , 'jshint' , 'concat' , 'uglify' ] ) ;
203+ grunt . option ( 'exclude' , 'ninja' ) ;
204+ grunt . option ( 'filename' , 'phaser' ) ;
205+ grunt . option ( 'sourcemap' , true ) ;
206+ grunt . option ( 'copy' , true ) ;
174207
175- grunt . registerTask ( 'dist' , [ 'replace:pixi' , 'replace:p2' , 'build' , 'copy' ] ) ;
208+ grunt . task . run ( 'custom' ) ;
176209
177- grunt . registerTask ( 'docs' , [ 'clean:docs' , 'pixidoc' , 'jsdoc:html' , 'replace:docs' , 'clean:out' ] ) ;
210+ } ) ;
211+
212+ grunt . registerTask ( 'arcadephysics' , 'Phaser with Arcade Physics, Tilemaps and Particles' , function ( ) {
213+
214+ grunt . option ( 'exclude' , 'ninja,p2' ) ;
215+ grunt . option ( 'filename' , 'phaser-arcade-physics' ) ;
216+ grunt . option ( 'sourcemap' , true ) ;
217+ grunt . option ( 'copy' , false ) ;
218+ grunt . option ( 'copycustom' , true ) ;
219+
220+ grunt . task . run ( 'custom' ) ;
221+
222+ } ) ;
223+
224+ grunt . registerTask ( 'nophysics' , 'Phaser without physics, tilemaps or particles' , function ( ) {
225+
226+ grunt . option ( 'exclude' , 'arcade,ninja,p2,tilemaps,particles' ) ;
227+ grunt . option ( 'filename' , 'phaser-no-physics' ) ;
228+ grunt . option ( 'sourcemap' , true ) ;
229+ grunt . option ( 'copy' , false ) ;
230+ grunt . option ( 'copycustom' , true ) ;
231+
232+ grunt . task . run ( 'custom' ) ;
233+
234+ } ) ;
235+
236+ grunt . registerTask ( 'minimum' , 'Phaser without any optional modules except Pixi' , function ( ) {
237+
238+ grunt . option ( 'exclude' , 'gamepad,keyboard,bitmapdata,graphics,rendertexture,text,bitmaptext,retrofont,net,tweens,sound,debug,arcade,ninja,p2,tilemaps,particles' ) ;
239+ grunt . option ( 'filename' , 'phaser-minimum' ) ;
240+ grunt . option ( 'sourcemap' , true ) ;
241+ grunt . option ( 'copy' , false ) ;
242+ grunt . option ( 'copycustom' , true ) ;
243+
244+ grunt . task . run ( 'custom' ) ;
245+
246+ } ) ;
178247
179- grunt . registerTask ( 'tsdocs' , [ 'clean:out' , 'pixidoc' , 'gitclone:plugins' , 'jsdoc:json' , 'buildtsdoc:pixi' , 'buildtsdoc:phaser' , 'replace:phasertsdefheader' , 'clean:out' ] ) ;
180248} ;
0 commit comments