webpack-dev-server 2.9.0 → 2.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -25
- package/bin/webpack-dev-server.js +9 -10
- package/client/index.bundle.js +1 -1
- package/client/index.js +19 -1
- package/client/live.bundle.js +3 -3
- package/client/socket.js +1 -1
- package/lib/Server.js +11 -6
- package/lib/optionsSchema.json +0 -3
- package/lib/polyfills.js +3 -4
- package/lib/util/createDomain.js +5 -1
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://github.com/webpack/webpack">
|
|
3
|
+
<img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
|
|
4
|
+
</a>
|
|
5
|
+
</div>
|
|
2
6
|
|
|
3
7
|
[![npm][npm]][npm-url]
|
|
4
8
|
[![node][node]][node-url]
|
|
@@ -7,62 +11,137 @@
|
|
|
7
11
|
[![coverage][cover]][cover-url]
|
|
8
12
|
[![chat][chat]][chat-url]
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
<a href="https://github.com/webpack/webpack">
|
|
12
|
-
<img width="200" height="200"
|
|
13
|
-
src="https://webpack.js.org/assets/icon-square-big.svg">
|
|
14
|
-
</a>
|
|
15
|
-
<h1>webpack Dev Server</h1>
|
|
16
|
-
</div>
|
|
14
|
+
# webpack-dev-server
|
|
17
15
|
|
|
18
|
-
Use [webpack](https://webpack.js.org) with a development server that provides
|
|
16
|
+
Use [webpack](https://webpack.js.org) with a development server that provides
|
|
17
|
+
live reloading. This should be used for **development only**.
|
|
19
18
|
|
|
20
|
-
It uses [webpack-dev-middleware]
|
|
19
|
+
It uses [webpack-dev-middleware][middleware-url] under the hood, which provides
|
|
20
|
+
fast in-memory access to the webpack assets.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
## Getting Started
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
First thing's first, install the module:
|
|
25
|
+
|
|
26
|
+
```console
|
|
25
27
|
npm install webpack-dev-server --save-dev
|
|
26
28
|
```
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
_Note: While you can install and run webpack-dev-server globally, we recommend
|
|
31
|
+
installing it locally. webpack-dev-server will always use a local installation
|
|
32
|
+
over a global one._
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
## Usage
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
There are two main, recommended methods of using the module:
|
|
37
|
+
|
|
38
|
+
### With the CLI
|
|
39
|
+
|
|
40
|
+
The easiest way to use it is with the CLI. In the directory where your
|
|
41
|
+
`webpack.config.js` is, run:
|
|
42
|
+
|
|
43
|
+
```console
|
|
33
44
|
node_modules/.bin/webpack-dev-server
|
|
34
45
|
```
|
|
35
46
|
|
|
36
|
-
|
|
47
|
+
### With NPM Scripts
|
|
48
|
+
|
|
49
|
+
NPM package.json scripts are a convenient and useful means to run locally installed
|
|
50
|
+
binaries without having to be concerned about their full paths. Simply define a
|
|
51
|
+
script as such:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
"scripts": {
|
|
55
|
+
"start:dev": "webpack-dev-server"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
And run the following in your terminal/console:
|
|
60
|
+
|
|
61
|
+
```console
|
|
62
|
+
npm run start:dev
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
NPM will automagically reference the binary in `node_modules` for you, and
|
|
66
|
+
execute the file or command.
|
|
67
|
+
|
|
68
|
+
### The Result
|
|
69
|
+
|
|
70
|
+
Either method will start a server instance and begin listening for connections
|
|
71
|
+
from `localhost` on port `8080`.
|
|
72
|
+
|
|
73
|
+
webpack-dev-server is configured by default to support live-reload of files as
|
|
74
|
+
you edit your assets while the server is running.
|
|
75
|
+
|
|
76
|
+
See [**the documentation**][docs-url] for more use cases and options.
|
|
77
|
+
|
|
78
|
+
## Caveats
|
|
79
|
+
|
|
80
|
+
Version 2.8.0 introduced a change which included ES6 keywords `const` and `let`
|
|
81
|
+
within the scripts being served to the browser. This effects environments which
|
|
82
|
+
support _no ES6 whatsoever_, including older versions of UglifyJS and Internet
|
|
83
|
+
Explorer. This was not considered a breaking change at the time due to official
|
|
84
|
+
support for oldIE ending in 2016, rather this was seen as a maintenance update.
|
|
85
|
+
Those wishing to support oldIE should stick with version 2.7.1.
|
|
37
86
|
|
|
38
|
-
|
|
87
|
+
For version 2.8.0+ those using UglifyJS in their webpack configs should use the
|
|
88
|
+
beta version of [uglifyjs-webpack-plugin][uglify-url] independently, and _not_
|
|
89
|
+
the built-in plugin. This will change once the new version is out of beta.
|
|
39
90
|
|
|
40
|
-
|
|
91
|
+
## Support
|
|
41
92
|
|
|
42
|
-
|
|
93
|
+
We do our best to keep Issues in the repository focused on bugs, features, and
|
|
94
|
+
needed modifications to the code for the module. Because of that, we ask users
|
|
95
|
+
with general support, "how-to", or "why isn't this working" questions to try one
|
|
96
|
+
of the other support channels that are available.
|
|
43
97
|
|
|
44
|
-
|
|
98
|
+
Your first-stop-shop for support for webpack-dev-server should by the excellent
|
|
99
|
+
[documentation][docs-url] for the module. If you see an opportunity for improvement
|
|
100
|
+
of those docs, please head over to the [webpack.js.org repo][wjo-url] and open a
|
|
101
|
+
pull request.
|
|
45
102
|
|
|
46
|
-
|
|
103
|
+
From there, we encourage users to visit the [webpack Gitter chat][chat-url] and
|
|
104
|
+
talk to the fine folks there. If your quest for answers comes up dry in chat,
|
|
105
|
+
head over to [StackOverflow][stack-url] and do a quick search or open a new
|
|
106
|
+
question. Remember; It's always much easier to answer questions that include your
|
|
107
|
+
`webpack.config.js` and relevant files!
|
|
108
|
+
|
|
109
|
+
If you're twitter-savvy you can tweet [#webpack][hash-url] with your question
|
|
110
|
+
and someone should be able to reach out and lend a hand.
|
|
111
|
+
|
|
112
|
+
If you have discovered a :bug:, have a feature suggestion, of would like to see
|
|
113
|
+
a modification, please feel free to create an issue on Github. _Note: The issue
|
|
114
|
+
template isn't optional, so please be sure not to remove it, and please fill it
|
|
115
|
+
out completely._
|
|
116
|
+
|
|
117
|
+
## Contributing
|
|
118
|
+
|
|
119
|
+
We welcome your contributions! Please have a read of [CONTRIBUTING.md](CONTRIBUTING.md) for more information on how to get involved.
|
|
120
|
+
|
|
121
|
+
## Maintainers
|
|
47
122
|
|
|
48
123
|
<table>
|
|
49
124
|
<tbody>
|
|
50
125
|
<tr>
|
|
51
126
|
<td align="center">
|
|
52
|
-
<img
|
|
53
|
-
src="https://avatars.githubusercontent.com/SpaceK33z?v=3">
|
|
127
|
+
<img src="https://avatars.githubusercontent.com/SpaceK33z?v=4&s=150">
|
|
54
128
|
<br />
|
|
55
129
|
<a href="https://github.com/SpaceK33z">Kees Kluskens</a>
|
|
56
130
|
</td>
|
|
131
|
+
<td align="center">
|
|
132
|
+
<img src="https://i.imgur.com/4v6pgxh.png">
|
|
133
|
+
<br />
|
|
134
|
+
<a href="https://github.com/shellscape">Andrew Powell</a>
|
|
135
|
+
</td>
|
|
57
136
|
</tr>
|
|
58
137
|
</tbody>
|
|
59
138
|
</table>
|
|
60
139
|
|
|
61
|
-
|
|
140
|
+
## Attribution
|
|
62
141
|
|
|
63
142
|
This project is heavily inspired by [peerigon/nof5](https://github.com/peerigon/nof5).
|
|
64
143
|
|
|
65
|
-
|
|
144
|
+
## License
|
|
66
145
|
|
|
67
146
|
#### [MIT](./LICENSE)
|
|
68
147
|
|
|
@@ -84,3 +163,10 @@ This project is heavily inspired by [peerigon/nof5](https://github.com/peerigon/
|
|
|
84
163
|
|
|
85
164
|
[chat]: https://badges.gitter.im/webpack/webpack.svg
|
|
86
165
|
[chat-url]: https://gitter.im/webpack/webpack
|
|
166
|
+
|
|
167
|
+
[docs-url]: https://webpack.js.org/configuration/dev-server/#devserver
|
|
168
|
+
[hash-url]: https://twitter.com/search?q=webpack
|
|
169
|
+
[middleware-url]: https://github.com/webpack/webpack-dev-middleware
|
|
170
|
+
[stack-url]: https://stackoverflow.com/questions/tagged/webpack-dev-server
|
|
171
|
+
[uglify-url]: https://github.com/webpack-contrib/uglifyjs-webpack-plugin
|
|
172
|
+
[wjo-url]: https://github.com/webpack/webpack.js.org
|
|
@@ -5,22 +5,20 @@
|
|
|
5
5
|
/* eslint global-require: off, import/order: off, no-console: off */
|
|
6
6
|
require('../lib/polyfills');
|
|
7
7
|
|
|
8
|
+
const debug = require('debug')('webpack-dev-server');
|
|
8
9
|
const fs = require('fs');
|
|
9
10
|
const net = require('net');
|
|
10
11
|
const path = require('path');
|
|
12
|
+
const importLocal = require('import-local');
|
|
11
13
|
const open = require('opn');
|
|
12
14
|
const portfinder = require('portfinder');
|
|
13
15
|
const addDevServerEntrypoints = require('../lib/util/addDevServerEntrypoints');
|
|
14
16
|
const createDomain = require('../lib/util/createDomain'); // eslint-disable-line
|
|
15
17
|
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
require(localWebpackDevServer); // eslint-disable-line
|
|
21
|
-
}
|
|
22
|
-
} catch (e) {
|
|
23
|
-
// eslint-disable-line
|
|
18
|
+
// Prefer the local installation of webpack-dev-server
|
|
19
|
+
if (importLocal(__filename)) {
|
|
20
|
+
debug('Using local install of webpack-dev-server');
|
|
21
|
+
return;
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
const Server = require('../lib/Server');
|
|
@@ -392,8 +390,9 @@ function startDevServer(webpackOptions, options) {
|
|
|
392
390
|
|
|
393
391
|
['SIGINT', 'SIGTERM'].forEach((sig) => {
|
|
394
392
|
process.on(sig, () => {
|
|
395
|
-
server.close()
|
|
396
|
-
|
|
393
|
+
server.close(() => {
|
|
394
|
+
process.exit(); // eslint-disable-line no-process-exit
|
|
395
|
+
});
|
|
397
396
|
});
|
|
398
397
|
});
|
|
399
398
|
|