@@ -4,6 +4,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
44const CopyPlugin = require ( 'copy-webpack-plugin' ) ;
55const HtmlConfig = require ( path . join ( __dirname , 'html.config' ) ) ;
66const CleanPlugin = require ( 'clean-webpack-plugin' ) ;
7+ const os = require ( 'os' ) ;
78
89const deploy = path . join ( __dirname , 'deploy' ) ;
910
@@ -14,6 +15,30 @@ module.exports = env => {
1415 new MiniCssExtractPlugin ( { filename : 'css/game.style.css' } ) ,
1516 new CopyPlugin ( [ { from : path . join ( __dirname + '/static' ) , to : deploy } ] )
1617 ] ;
18+
19+ // Get running network information
20+ let networkInfo = os . networkInterfaces ( ) ;
21+ let ipAddress ;
22+
23+ // Depending on operating system the network interface will be named differntly. Check if each exists to find the correct syntax
24+ if ( networkInfo . en0 ) {
25+ ipAddress = networkInfo . en0 [ 1 ] . address ;
26+ } else if ( networkInfo . en7 ) {
27+ ipAddress = networkInfo . en7 [ 1 ] . address ;
28+ } else if ( networkInfo [ 'Wi-Fi' ] ) {
29+ ipAddress = networkInfo [ 'Wi-Fi' ] [ 1 ] . address ;
30+ } else if ( networkInfo [ 'Ethernet' ] ) {
31+ ipAddress = networkInfo [ 'Ethernet' ] [ 1 ] . address ;
32+ } else if ( networkInfo . eth0 ) {
33+ ipAddress = networkInfo . eth0 [ 1 ] . address ;
34+ }
35+
36+ if ( ipAddress ) {
37+ console . log ( '\x1b[36m%s\x1b[0m' , "NETWORK HOST: http://" + ipAddress + ":8080" )
38+ } else {
39+ console . log ( '\x1b[36m%s\x1b[0m' , "Unable to find network address" ) ;
40+ }
41+
1742 return {
1843 stats : 'errors-only' ,
1944
0 commit comments