| 
									
										
										
										
											2017-01-17 13:40:59 +01:00
										 |  |  | #!/usr/bin/env node
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-06 14:22:17 +02:00
										 |  |  | const path = require('path'); | 
					
						
							| 
									
										
										
										
											2017-05-16 16:32:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-06 14:22:17 +02:00
										 |  |  | const chalk = require('chalk'); | 
					
						
							|  |  |  | const shelljs = require('shelljs'); | 
					
						
							| 
									
										
										
										
											2017-01-17 13:40:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-06 14:22:17 +02:00
										 |  |  | const animateProgress = require('./helpers/progress'); | 
					
						
							|  |  |  | const addCheckMark = require('./helpers/checkmark'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const progress = animateProgress('Generating stats'); | 
					
						
							| 
									
										
										
										
											2017-01-17 13:40:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Generate stats.json file with webpack
 | 
					
						
							|  |  |  | shelljs.exec( | 
					
						
							| 
									
										
										
										
											2017-05-16 16:32:54 +02:00
										 |  |  |   `./node_modules/strapi-helper-plugin/node_modules/webpack/bin/webpack.js --config ${path.resolve(__dirname, '..', 'webpack', 'webpack.prod.babel.js')} --profile --json > stats.json`, | 
					
						
							| 
									
										
										
										
											2017-01-17 13:40:59 +01:00
										 |  |  |   addCheckMark.bind(null, callback) // Output a checkmark on completion
 | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Called after webpack has finished generating the stats.json file
 | 
					
						
							|  |  |  | function callback() { | 
					
						
							|  |  |  |   clearInterval(progress); | 
					
						
							|  |  |  |   process.stdout.write( | 
					
						
							| 
									
										
										
										
											2017-06-06 14:22:17 +02:00
										 |  |  |     `
 | 
					
						
							|  |  |  |     \n\nOpen ${chalk.magenta('http://webpack.github.io/analyse/')} in your browser and upload the stats.json file! | 
					
						
							|  |  |  |     ${chalk.blue('\n(Tip: (\'CMD + double-click\') the link!)\n\n')} | 
					
						
							|  |  |  |     `
 | 
					
						
							| 
									
										
										
										
											2017-01-17 13:40:59 +01:00
										 |  |  |   ); | 
					
						
							|  |  |  | } |