1 | [tests]: https://img.shields.io/circleci/project/github/shellscape/webpack-serve.svg
|
2 | [tests-url]: https://circleci.com/gh/shellscape/webpack-serve
|
3 |
|
4 | [cover]: https://codecov.io/gh/shellscape/webpack-serve/branch/master/graph/badge.svg
|
5 | [cover-url]: https://codecov.io/gh/shellscape/webpack-serve
|
6 |
|
7 | [size]: https://packagephobia.now.sh/badge?p=webpack-serve
|
8 | [size-url]: https://packagephobia.now.sh/result?p=webpack-serve
|
9 |
|
10 | [https]: https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
|
11 | [http2]: https://nodejs.org/api/http2.html#http2_http2_createserver_options_onrequesthandler
|
12 | [http2tls]: https://nodejs.org/api/http2.html#http2_http2_createsecureserver_options_onrequesthandler
|
13 |
|
14 | <div align="center">
|
15 | <img width="256" src="https://raw.githubusercontent.com/shellscape/webpack-serve/master/assets/serve.svg?sanitize=true" alt="webpack-serve"><br/><br/>
|
16 | </div>
|
17 |
|
18 | [![tests][tests]][tests-url]
|
19 | [![cover][cover]][cover-url]
|
20 | [![size][size]][size-url]
|
21 |
|
22 | # webpack-serve
|
23 |
|
24 | A CLI for [`webpack-plugin-serve`](https://github.com/shellscape/webpack-plugin-serve) - A Webpack development server in a plugin.
|
25 |
|
26 | _(While using a CLI such as webpack-serve is convenient, we recommend using [`webpack-plugin-serve`](https://github.com/shellscape/webpack-plugin-serve) directly in your webpack config, with [`webpack-nano`](https://github.com/shellscape/webpack-nano), instead.)_
|
27 |
|
28 | <a href="https://www.patreon.com/shellscape">
|
29 | <img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
|
30 | </a>
|
31 |
|
32 | _Please consider donating if you find this project useful._
|
33 |
|
34 | ## Requirements
|
35 |
|
36 | `webpack-serve` is an [evergreen 🌲](./.github/FAQ.md#what-does-evergreen-mean) module.
|
37 |
|
38 | This module requires an [Active LTS](https://github.com/nodejs/Release) Node version (v8.0.0+ or v10.0.0+). The client scripts in this module require [browsers which support `async/await`](https://caniuse.com/#feat=async-functions). Users may also choose to compile the client script via an appropriately configured [Babel](https://babeljs.io/) webpack loader for use in older browsers.
|
39 |
|
40 | ## Feature Parity
|
41 |
|
42 | Since this CLI leverages `webpack-plugin-serve`, the same feature parity information applies. Please see the [`webpack-plugin-serve` Feature Comparison](https://github.com/shellscape/webpack-plugin-serve/blob/HEAD/.github/FEATURES.md) for more information.
|
43 |
|
44 | ## Install
|
45 |
|
46 | Using npm:
|
47 |
|
48 | ```console
|
49 | npm install webpack-serve --save-dev
|
50 | ```
|
51 |
|
52 | ## Usage
|
53 |
|
54 | ```console
|
55 | A CLI for webpack-plugin-serve, providing a premier webpack development server
|
56 |
|
57 | Usage
|
58 | $ webpack-serve [...options]
|
59 |
|
60 | Options
|
61 | --all Apply webpack-plugin-serve to all compilers in the config
|
62 | --client.address Overrides the WebSocket address in the client
|
63 | --client.retry Instructs the client to attempt to reconnect all WebSockets when interrupted
|
64 | --client.silent Instructs the client not to log anything to the console.
|
65 | --compress Enables compression middleware which serves files with GZip compression.
|
66 | --config A path to a webpack config file
|
67 | --config.{name} A path to a webpack config file, and the config name to run
|
68 | --help Displays this message
|
69 | --history-fallback Enables History API Fallback
|
70 | --hmr Enables Hot Module Replacement. On by default
|
71 | --host Sets the host the server should listen from
|
72 | --http2 Instructs the server to enable HTTP2
|
73 | --live-reload Instructs the client to perform a full page reload after each build
|
74 | --no-watch Does not apply \`watch: true\` to the config, allowing for greater customization
|
75 | --open Opens the default browser to the set host and port
|
76 | --port Sets the port on which the server should listen
|
77 | --progress Shows build progress in the client
|
78 | --silent Instruct the CLI to produce no console output
|
79 | --static Sets the directory from which static files will be served
|
80 | --status Shows build status (errors, warnings) in the client
|
81 | --version Displays webpack-nano and webpack versions
|
82 | --wait-for-build Instructs the server to halt middleware processing until the current build is done.
|
83 |
|
84 | Examples
|
85 | $ webpack-serve
|
86 | $ webpack-serve --help
|
87 | $ webpack-serve --config webpack.config.js
|
88 | $ webpack-serve --config.serve webpack.config.js
|
89 | ```
|
90 |
|
91 | ## Flags
|
92 |
|
93 | Please reference the [`webpack-plugin-serve` Options](https://github.com/shellscape/webpack-plugin-serve#options) for information and use. Most options are analogous to the flags listed above.
|
94 |
|
95 | #### `--no-watch`
|
96 |
|
97 | By default, the CLI will apply `watch: true` to the first config in the targeted webpack config file. To customize watching or `watchOptions`, please use this flag and customize the config(s) accordingly.
|
98 |
|
99 | ## package.json Options
|
100 |
|
101 | For convenience, `webpack-plugin-serve` options can also be defined in a `package.json` file. This CLI will look for a `serve` key in the nearest `package.json` beginning in the directory containing the specified `webpack.config.js`, up to the current working directory. Please reference the [`webpack-plugin-serve` Options](https://github.com/shellscape/webpack-plugin-serve#options) for information and use.
|
102 |
|
103 | For Example:
|
104 |
|
105 | ```json
|
106 | {
|
107 | "name": "some-package",
|
108 | "version": "1.0.0",
|
109 | "serve": {
|
110 | "host": "10.10.10.1"
|
111 | }
|
112 | }
|
113 | ```
|
114 |
|
115 | ## Advanced Options
|
116 |
|
117 | For options which require providing functions or complex objects like `Promises` which cannot be represented by JSON, nor on the command line, please use [`webpack-plugin-serve`](https://github.com/shellscape/webpack-plugin-serve) directly in your webpack config, along with [`webpack-nano`](https://github.com/shellscape/webpack-nano).
|
118 |
|
119 | ## Meta
|
120 |
|
121 | [CONTRIBUTING](./.github/CONTRIBUTING.md)
|
122 |
|
123 | [LICENSE (Mozilla Public License)](./LICENSE)
|