Skip to content

Commit be21827

Browse files
committed
Add more examples.
Ref #581
1 parent 6d064d9 commit be21827

File tree

34 files changed

+228
-5
lines changed

34 files changed

+228
-5
lines changed

examples/cli-public/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# https
2+
3+
NOTE: replace `<insert local ip>` with your local ip.
4+
5+
```shell
6+
node ../../bin/webpack-dev-server.js --open --host 0.0.0.0 --public <insert local ip>:8080
7+
```
8+
9+
If you want to make the client publicly accessible, the client needs to know with what host to connect to the server. If `--host 0.0.0.0` is given, the client would try to connect to `0.0.0.0`. With `--public` it is possible to override this.
10+
11+
## What should happen
12+
13+
The script should open `http://0.0.0.0:8080/`. In the app you should see "It's working."
14+
15+
Verify that the websocket is connecting to `<insert local ip>:8080`. Go to devtools -> Network, click on "websocket" and check "Request URL".

examples/cli-public/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
document.write("It's working.");

examples/cli-public/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="bundle.js" type="text/javascript" charset="utf-8"></script>
5+
</head>
6+
<body>
7+
<h1>Example: CLI public</h1>
8+
</body>
9+
</html>

examples/cli-public/webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
context: __dirname,
3+
entry: "./app.js",
4+
}

examples/cli-stdin/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# https
2+
3+
```shell
4+
node ../../bin/webpack-dev-server.js --stdin
5+
```
6+
7+
When stdin ends, we want to close the webpack-dev-server.
8+
9+
## What should happen
10+
11+
The script should start up. When `ctrl+D` is pressed, the server should quit. Note that the shortcut can differ on operating systems, but the point is to signify the end of input.

examples/cli-stdin/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
document.write("It's working.");

examples/cli-stdin/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="bundle.js" type="text/javascript" charset="utf-8"></script>
5+
</head>
6+
<body>
7+
<h1>Example: CLI - stdin</h1>
8+
</body>
9+
</html>

examples/cli-stdin/webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
context: __dirname,
3+
entry: "./app.js",
4+
}

examples/compression/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Compression
2+
3+
```shell
4+
node ../../bin/webpack-dev-server.js --open --compress
5+
```
6+
7+
Gzip compression is enabled.
8+
9+
## What should happen
10+
11+
The script should open `https://localhost:8080/`.
12+
13+
Open the devtools -> `Network` tab, and find `bundle.js`. The response headers should have a `Content-Encoding: gzip` header.

examples/compression/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
document.write("It's working.");

0 commit comments

Comments
 (0)