Skip to content

Commit

Permalink
docs: improve examples (#3672)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Aug 18, 2021
1 parent f2d87fb commit 4f5bab1
Show file tree
Hide file tree
Showing 73 changed files with 480 additions and 170 deletions.
13 changes: 12 additions & 1 deletion examples/cli/bonjour/README.md → examples/bonjour/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
The Bonjour capability broadcasts server information via ZeroConf when the Server
is started.

To run this example, run this command in your console or terminal:
**webpack.config.js**

```js
module.exports = {
// ...
devServer: {
bonjour: true,
},
};
```

Usage via CLI:

```console
npx webpack serve --bonjour
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// our setup function adds behind-the-scenes bits to the config that all of our
// examples need
const { setup } = require("../../util");
const { setup } = require("../util");

module.exports = setup({
context: __dirname,
Expand Down
31 changes: 0 additions & 31 deletions examples/cli/https/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions examples/cli/https/webpack.config.js

This file was deleted.

34 changes: 0 additions & 34 deletions examples/cli/open-target/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions examples/cli/progress/webpack.config.js

This file was deleted.

10 changes: 0 additions & 10 deletions examples/cli/web-socket-server/webpack.config.js

This file was deleted.

21 changes: 0 additions & 21 deletions examples/cli/web-socket-url-cli/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions examples/cli/web-socket-url-cli/app.js

This file was deleted.

10 changes: 0 additions & 10 deletions examples/cli/web-socket-url-cli/webpack.config.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ to roughly 30% of its original size before the files are sent to the browser.

It is enabled by default.

## `--compress`
## true

To run this example, run this command in your console or terminal:
**webpack.config.js**

```js
module.exports = {
// ...
devServer: {
compress: true,
},
};
```

Usage via CLI:

```console
npx webpack serve --open --compress
Expand All @@ -20,9 +31,20 @@ npx webpack serve --open --compress
3. Open the console in your browser's devtools and select the _Network_ tab.
4. Find `bundle.js`. The response headers should contain `Content-Encoding: gzip`.

## `--no-compress`
## false

**webpack.config.js**

```js
module.exports = {
// ...
devServer: {
compress: false,
},
};
```

To run this example, run this command in your console or terminal:
Usage via CLI:

```console
npx webpack serve --open --no-compress
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// our setup function adds behind-the-scenes bits to the config that all of our
// examples need
const { setup } = require("../../util");
const { setup } = require("../util");

module.exports = setup({
context: __dirname,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CLI: Default State
# Default State

This example demonstrates how to use `webpack-dev-server`.

Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// our setup function adds behind-the-scenes bits to the config that all of our
// examples need
const { setup } = require("../../util");
const { setup } = require("../util");

module.exports = setup({
context: __dirname,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# CLI: History API Fallback Option
# historyApiFallback Option

This option enables [History API Fallback](https://github.com/bripkens/connect-history-api-fallback)
support in `webpack-dev-server`, effectively asking the server to fallback to
`index.html` in the event that a requested resource cannot be found.

```shell
**webpack.config.js**

```js
module.exports = {
// ...
devServer: {
historyApiFallback: true,
},
};
```

Usage via CLI:

```console
npx webpack serve --open --history-api-fallback
```

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// our setup function adds behind-the-scenes bits to the config that all of our
// examples need
const { setup } = require("../../util");
const { setup } = require("../util");

module.exports = setup({
context: __dirname,
Expand Down
32 changes: 29 additions & 3 deletions examples/cli/hmr/README.md → examples/hmr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,22 @@
Hot Module Replacement (HMR) exchanges, adds, or removes modules while an
application is running, without a full reload of the page.

## --hot
## true

To run this example, run this command in your console or terminal:
Enable webpack's [Hot Module Replacement](https://webpack.js.org/concepts/hot-module-replacement/) feature:

**webpack.config.js**

```js
module.exports = {
// ...
devServer: {
hot: true,
},
};
```

Usage via CLI:

```console
npx webpack serve --open --hot
Expand All @@ -31,10 +44,23 @@ In the devtools console you should see:
You should also see the text on the page itself change to match your edits in
`example.js`.

## --hot only
## only

Enables Hot Module Replacement without page refresh as a fallback in case of build failures.

**webpack.config.js**

```js
module.exports = {
// ...
devServer: {
hot: "only",
},
};
```

Usage via CLI:

```console
npx webpack serve --open --hot only
```
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// our setup function adds behind-the-scenes bits to the config that all of our
// examples need
const { setup } = require("../../util");
const { setup } = require("../util");

module.exports = setup({
context: __dirname,
Expand Down
Loading

0 comments on commit 4f5bab1

Please sign in to comment.