File tree 9 files changed +195
-0
lines changed
examples/client/reconnect
9 files changed +195
-0
lines changed Original file line number Diff line number Diff line change
1
+ # client.reconnect: false
2
+
3
+ ## false
4
+
5
+ Tells dev-server the number of times it should try to reconnect the client. When ` false ` it will not try to reconnect.
6
+
7
+ ** webpack.config.js**
8
+
9
+ ``` js
10
+ module .exports = {
11
+ // ...
12
+ devServer: {
13
+ client: {
14
+ reconect: false ,
15
+ },
16
+ },
17
+ };
18
+ ```
19
+
20
+ Usage via CLI:
21
+
22
+ ``` shell
23
+ npx webpack serve --open --no-client-reconnect
24
+ ```
25
+
26
+ ## What Should Happen
27
+
28
+ 1 . The script should open ` http://localhost:8080/ ` in your default browser.
29
+ 2 . Open the console tab in your browser's devtools.
30
+ 3 . Now close the server with ` Ctrl+C ` to disconnect the client.
31
+
32
+ In the devtools console you should see that webpack-dev-server is not trying to reconnect:
33
+
34
+ ```
35
+ [webpack-dev-server] Hot Module Replacement enabled.
36
+ [webpack-dev-server] Live Reloading enabled.
37
+ [webpack-dev-server] Disconnected!
38
+ ```
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+
3
+ const target = document . querySelector ( "#target" ) ;
4
+
5
+ target . classList . add ( "pass" ) ;
6
+ target . innerHTML =
7
+ "Success! <br> Now, open the console tab in your browser's devtools. Then, close the server with `Ctrl+C` to disconnect the client." ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+
3
+ // our setup function adds behind-the-scenes bits to the config that all of our
4
+ // examples need
5
+ const { setup } = require ( "../../../util" ) ;
6
+
7
+ module . exports = setup ( {
8
+ context : __dirname ,
9
+ entry : "./app.js" ,
10
+ devServer : {
11
+ client : {
12
+ reconnect : false ,
13
+ } ,
14
+ } ,
15
+ } ) ;
Original file line number Diff line number Diff line change
1
+ # client.reconnect Option
2
+
3
+ ## number
4
+
5
+ Tells dev-server the number of times it should try to reconnect the client.
6
+
7
+ ** webpack.config.js**
8
+
9
+ ``` js
10
+ module .exports = {
11
+ // ...
12
+ devServer: {
13
+ client: {
14
+ reconect: 2 ,
15
+ },
16
+ },
17
+ };
18
+ ```
19
+
20
+ Usage via CLI:
21
+
22
+ ``` shell
23
+ npx webpack serve --open --client-reconnect 2
24
+ ```
25
+
26
+ ## What Should Happen
27
+
28
+ 1 . The script should open ` http://localhost:8080/ ` in your default browser.
29
+ 2 . Open the console tab in your browser's devtools.
30
+ 3 . Now close the server with ` Ctrl+C ` to disconnect the client.
31
+
32
+ In the devtools console you should see that webpack-dev-server tried to reconnect the client 2 times:
33
+
34
+ ```
35
+ [webpack-dev-server] Hot Module Replacement enabled.
36
+ [webpack-dev-server] Live Reloading enabled.
37
+ [webpack-dev-server] Disconnected!
38
+ [webpack-dev-server] Trying to reconnect...
39
+ WebSocket connection to 'ws://127.0.0.1:8163/ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
40
+ [webpack-dev-server] JSHandle@object
41
+ [webpack-dev-server] Trying to reconnect...
42
+ WebSocket connection to 'ws://127.0.0.1:8163/ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
43
+ [webpack-dev-server] JSHandle@object
44
+ ```
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+
3
+ const target = document . querySelector ( "#target" ) ;
4
+
5
+ target . classList . add ( "pass" ) ;
6
+ target . innerHTML =
7
+ "Success! <br> Now, open the console tab in your browser's devtools. Then, close the server with `Ctrl+C` to disconnect the client." ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+
3
+ // our setup function adds behind-the-scenes bits to the config that all of our
4
+ // examples need
5
+ const { setup } = require ( "../../../util" ) ;
6
+
7
+ module . exports = setup ( {
8
+ context : __dirname ,
9
+ entry : "./app.js" ,
10
+ devServer : {
11
+ client : {
12
+ reconnect : 2 ,
13
+ } ,
14
+ } ,
15
+ } ) ;
Original file line number Diff line number Diff line change
1
+ # client.reconnect: true
2
+
3
+ ## true
4
+
5
+ Tells dev-server the number of times it should try to reconnect the client. When ` true ` it will try to reconnect unlimited times.
6
+
7
+ ** webpack.config.js**
8
+
9
+ ``` js
10
+ module .exports = {
11
+ // ...
12
+ devServer: {
13
+ client: {
14
+ reconect: true ,
15
+ },
16
+ },
17
+ };
18
+ ```
19
+
20
+ Usage via CLI:
21
+
22
+ ``` shell
23
+ npx webpack serve --open --client-reconnect
24
+ ```
25
+
26
+ ## What Should Happen
27
+
28
+ 1 . The script should open ` http://localhost:8080/ ` in your default browser.
29
+ 2 . Open the console tab in your browser's devtools.
30
+ 3 . Now close the server with ` Ctrl+C ` to disconnect the client.
31
+
32
+ In the devtools console you should see that webpack-dev-server is trying to reconnect:
33
+
34
+ ```
35
+ [webpack-dev-server] Hot Module Replacement enabled.
36
+ [webpack-dev-server] Live Reloading enabled.
37
+ [webpack-dev-server] Disconnected!
38
+ [webpack-dev-server] Trying to reconnect...
39
+ WebSocket connection to 'ws://127.0.0.1:8163/ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
40
+ [webpack-dev-server] JSHandle@object
41
+ [webpack-dev-server] Trying to reconnect...
42
+ WebSocket connection to 'ws://127.0.0.1:8163/ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
43
+ [webpack-dev-server] JSHandle@object
44
+ [webpack-dev-server] Trying to reconnect...
45
+ WebSocket connection to 'ws://127.0.0.1:8163/ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
46
+ [webpack-dev-server] JSHandle@object
47
+ ```
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+
3
+ const target = document . querySelector ( "#target" ) ;
4
+
5
+ target . classList . add ( "pass" ) ;
6
+ target . innerHTML =
7
+ "Success! <br> Now, open the console tab in your browser's devtools. Then, close the server with `Ctrl+C` to disconnect the client." ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+
3
+ // our setup function adds behind-the-scenes bits to the config that all of our
4
+ // examples need
5
+ const { setup } = require ( "../../../util" ) ;
6
+
7
+ module . exports = setup ( {
8
+ context : __dirname ,
9
+ entry : "./app.js" ,
10
+ devServer : {
11
+ client : {
12
+ reconnect : true ,
13
+ } ,
14
+ } ,
15
+ } ) ;
You can’t perform that action at this time.
0 commit comments