File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -28,3 +28,6 @@ node_modules
2828
2929# Bower
3030bower_components /
31+
32+ # IDE/Editor data
33+ .idea
Original file line number Diff line number Diff line change @@ -6,12 +6,31 @@ const WebpackDevServer = require('webpack-dev-server');
66const config = require ( './webpack.config' ) ;
77const open = require ( 'open' ) ;
88
9- new WebpackDevServer ( webpack ( config ) , config . devServer )
9+ /**
10+ * Flag indicating whether webpack compiled for the first time.
11+ * @type {boolean }
12+ */
13+ let isInitialCompilation = true ;
14+
15+ const compiler = webpack ( config ) ;
16+
17+ new WebpackDevServer ( compiler , config . devServer )
1018. listen ( config . port , 'localhost' , ( err ) => {
1119 if ( err ) {
1220 console . log ( err ) ;
1321 }
1422 console . log ( 'Listening at localhost:' + config . port ) ;
15- console . log ( 'Opening your system browser...' ) ;
16- open ( 'http://localhost:' + config . port + '/webpack-dev-server/' ) ;
23+ } ) ;
24+
25+ compiler . plugin ( 'done' , ( ) => {
26+ if ( isInitialCompilation ) {
27+ // Ensures that we log after webpack printed its stats (is there a better way?)
28+ setTimeout ( ( ) => {
29+ console . log ( '\n✓ The bundle is now ready for serving!\n' ) ;
30+ console . log ( ' Open in iframe Mode:\t\x1b[33m%s\x1b[0m' , 'http://localhost:' + config . port + '/webpack-dev-server/' ) ;
31+ console . log ( ' Open in inline Mode:\t\x1b[33m%s\x1b[0m' , 'http://localhost:' + config . port + '/\n' ) ;
32+ console . log ( ' \x1b[33mHRM is active\x1b[0m. The bundle will automatically rebuild and live-update on changes.' )
33+ } , 350 ) ;
34+ }
35+ isInitialCompilation = false ;
1736} ) ;
You can’t perform that action at this time.
0 commit comments