Skip to content

Commit 94f1dda

Browse files
authored
Merge branch 'master' into dev-server-property
2 parents 7c74c05 + d4c9b8f commit 94f1dda

File tree

11 files changed

+1588
-1299
lines changed

11 files changed

+1588
-1299
lines changed

CODE_OF_CONDUCT.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Code of Conduct
2+
3+
At webpack and webpack/webpack-dev-server repository we follow the [JSFoundation Code of Conduct][1].
4+
Please adhere to the guidelines there and feel free to report any violation of them to the **@webpack/core-team**,
5+
**@webpack/dev-server-team**, or <[email protected]>.
6+
7+
[1]: https://github.com/openjs-foundation/code-and-learn/blob/main/CODE_OF_CONDUCT.md

CONTRIBUTING.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,24 @@ Following these guidelines helps to communicate that you respect the time of the
1010

1111
- There are hooks to add your own features, so we should not add less-common features.
1212
- The workflow should be to start webpack-dev-server as a separate process, next to the "normal" server and to request the script from this server or to proxy from dev-server to "normal" server (because webpack blocks the event queue too much while compiling which can affect "normal" server).
13-
- A user should not try to implement stuff that accesses the webpack filesystem. This lead to bugs (the middleware does it while blocking requests until the compilation has finished, the blocking is important).
13+
- A user should not try to implement stuff that accesses the webpack filesystem. This leads to bugs (the middleware does it while blocking requests until the compilation has finished, the blocking is important).
1414
- It should be a development only tool. Compiling in production is bad, one should precompile and deliver the compiled assets.
1515
- Processing options and stats display is delegated to webpack, so webpack-dev-server/middleware should not do much with it. This also helps us to keep up-to-date with webpack updates.
1616
- The communication library (`SockJS`) should not be exposed to the user.
1717

1818
## Submitting a Pull Request
1919

20-
Good pull requests, such as patches, improvements, and new features, are a fantastic help. They should remain focused in scope and not contain unrelated commits.
20+
- Good pull requests, such as patches, improvements, and new features, are a fantastic help. They should remain focused in scope and not contain unrelated commits.
2121

22-
It is advised to first create an issue (if there is not one already) before making a pull request. This way the maintainers can first discuss with you if they agree and it also helps with providing some context.
22+
- It is advised to first create an issue (if there is not one already) before making a pull request. This way the maintainers can first discuss with you if they agree and it also helps with providing some context.
2323

24-
Run the relevant [examples](https://github.com/webpack/webpack-dev-server/tree/master/examples) to see if all functionality still works. When introducing new functionality, also add an example. This helps the maintainers to understand it and check if it still works.
24+
- Run the relevant [examples](https://github.com/webpack/webpack-dev-server/tree/master/examples) to see if all functionality still works. When introducing new functionality, also add an example. This helps the maintainers to understand it and check if it still works.
25+
26+
- Write tests.
27+
28+
- Follow the existing coding style.
29+
30+
- Make sure your PR's description contains GitHub's special keyword references that automatically close the related issue when the PR is merged. ([More info](https://github.com/blog/1506-closing-issues-via-pull-requests))
2531

2632
## Setting Up a Local Copy
2733

@@ -31,7 +37,7 @@ Run the relevant [examples](https://github.com/webpack/webpack-dev-server/tree/m
3137

3238
3. Run `npm link && npm link webpack-dev-server` to link the current project to `node_modules`.
3339

34-
Once it is done, you can modify any file locally. In the `examples/` directory you'll find a lot of examples with instructions on how to run it. This can be very handy when testing if your code works.
40+
Once it is done, you can modify any file locally. In the `examples/` directory you'll find a lot of examples with instructions on how to run them. This can be very handy when testing if your code works.
3541

3642
If you are modifying a file in the `client/` directory, be sure to run `npm run build:client` after it. This will recompile the files.
3743

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ Options:
102102
--history-api-fallback Fallback to /index.html for Single Page Applications.
103103
--compress Enable gzip compression.
104104
--public <value> The public hostname/ip address of the server.
105-
--firewall <value...> Enable/disable firewall, or set hosts that are allowed to access the dev server.
105+
--firewall [value...] Enable firewall or set hosts that are allowed to access the dev server.
106+
--no-firewall Disable firewall.
106107
107108
Global options:
108109
--color Enable colors on console.
@@ -161,7 +162,7 @@ needed modifications to the code for the module. Because of that, we ask users
161162
with general support, "how-to", or "why isn't this working" questions to try one
162163
of the other support channels that are available.
163164

164-
Your first-stop-shop for support for webpack-dev-server should by the excellent
165+
Your first-stop-shop for support for webpack-dev-server should be the excellent
165166
[documentation][docs-url] for the module. If you see an opportunity for improvement
166167
of those docs, please head over to the [webpack.js.org repo][wjo-url] and open a
167168
pull request.

bin/cli-flags.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ module.exports = {
3030
name: 'https',
3131
type: Boolean,
3232
description: 'Use HTTPS protocol.',
33+
negatedDescription: 'Do not use HTTPS protocol.',
34+
negative: true,
3335
},
3436
{
3537
name: 'http2',
3638
type: Boolean,
3739
description: 'Use HTTP/2, must be used with HTTPS.',
40+
negatedDescription: 'Do not use HTTP/2.',
41+
negative: true,
3842
},
3943
{
4044
name: 'bonjour',
@@ -105,11 +109,16 @@ module.exports = {
105109
name: 'history-api-fallback',
106110
type: Boolean,
107111
description: 'Fallback to /index.html for Single Page Applications.',
112+
negatedDescription:
113+
'Do not fallback to /index.html for Single Page Applications.',
114+
negative: true,
108115
},
109116
{
110117
name: 'compress',
111118
type: Boolean,
112119
description: 'Enable gzip compression.',
120+
negatedDescription: 'Disable gzip compression.',
121+
negative: true,
113122
},
114123
{
115124
name: 'public',
@@ -118,10 +127,12 @@ module.exports = {
118127
},
119128
{
120129
name: 'firewall',
121-
type: String,
130+
type: [String, Boolean],
122131
description:
123-
'Enable/disable firewall, or set hosts that are allowed to access the dev server.',
132+
'Enable firewall or set hosts that are allowed to access the dev server.',
133+
negatedDescription: 'Disable firewall.',
124134
multiple: true,
135+
negative: true,
125136
},
126137
],
127138
};

client-src/default/index.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,48 @@ self.addEventListener('beforeunload', () => {
3030

3131
if (typeof window !== 'undefined') {
3232
const qs = window.location.search.toLowerCase();
33+
3334
options.hotReload = qs.indexOf('hotreload=false') === -1;
3435
}
3536

3637
const onSocketMessage = {
3738
hot() {
3839
options.hot = true;
40+
3941
log.info('Hot Module Replacement enabled.');
4042
},
4143
liveReload() {
4244
options.liveReload = true;
45+
4346
log.info('Live Reloading enabled.');
4447
},
4548
invalid() {
4649
log.info('App updated. Recompiling...');
50+
4751
// fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
4852
if (options.useWarningOverlay || options.useErrorOverlay) {
4953
overlay.clear();
5054
}
55+
5156
sendMessage('Invalid');
5257
},
5358
hash(hash) {
5459
status.currentHash = hash;
5560
},
5661
'still-ok': function stillOk() {
5762
log.info('Nothing changed.');
63+
5864
if (options.useWarningOverlay || options.useErrorOverlay) {
5965
overlay.clear();
6066
}
67+
6168
sendMessage('StillOk');
6269
},
6370
logging: function logging(level) {
6471
// this is needed because the HMR logger operate separately from
6572
// dev server logger
6673
const hotCtx = require.context('webpack/hot', false, /^\.\/log$/);
74+
6775
if (hotCtx.keys().indexOf('./log') !== -1) {
6876
hotCtx('./log').setLogLevel(level);
6977
}
@@ -90,29 +98,40 @@ const onSocketMessage = {
9098
if (options.useProgress) {
9199
log.info(`${data.percent}% - ${data.msg}.`);
92100
}
101+
93102
sendMessage('Progress', data);
94103
},
95104
ok() {
96105
sendMessage('Ok');
106+
97107
if (options.useWarningOverlay || options.useErrorOverlay) {
98108
overlay.clear();
99109
}
110+
100111
if (options.initial) {
101112
return (options.initial = false);
102113
}
114+
103115
reloadApp(options, status);
104116
},
105117
'content-changed': function contentChanged() {
106118
log.info('Content base changed. Reloading...');
119+
107120
self.location.reload();
108121
},
109122
warnings(warnings) {
110123
log.warn('Warnings while compiling.');
111-
const strippedWarnings = warnings.map((warning) => stripAnsi(warning));
124+
125+
const strippedWarnings = warnings.map((warning) =>
126+
stripAnsi(warning.message ? warning.message : warning)
127+
);
128+
112129
sendMessage('Warnings', strippedWarnings);
130+
113131
for (let i = 0; i < strippedWarnings.length; i++) {
114132
log.warn(strippedWarnings[i]);
115133
}
134+
116135
if (options.useWarningOverlay) {
117136
overlay.showMessage(warnings);
118137
}
@@ -125,16 +144,21 @@ const onSocketMessage = {
125144
},
126145
errors(errors) {
127146
log.error('Errors while compiling. Reload prevented.');
147+
128148
const strippedErrors = errors.map((error) =>
129149
stripAnsi(error.message ? error.message : error)
130150
);
151+
131152
sendMessage('Errors', strippedErrors);
153+
132154
for (let i = 0; i < strippedErrors.length; i++) {
133155
log.error(strippedErrors[i]);
134156
}
157+
135158
if (options.useErrorOverlay) {
136159
overlay.showMessage(errors);
137160
}
161+
138162
options.initial = false;
139163
},
140164
error(error) {

client-src/default/overlay.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
// They, in turn, got inspired by webpack-hot-middleware (https://github.com/glenjamin/webpack-hot-middleware).
55

66
const ansiHTML = require('ansi-html');
7-
const { AllHtmlEntities } = require('html-entities');
7+
const { encode } = require('html-entities');
88

9-
const entities = new AllHtmlEntities();
109
const colors = {
1110
reset: ['transparent', 'transparent'],
1211
black: '181818',
@@ -114,7 +113,7 @@ function showMessage(messages) {
114113
ensureOverlayDivExists((div) => {
115114
// Make it look similar to our terminal.
116115
const errorMessage = messages[0].message || messages[0];
117-
const text = ansiHTML(entities.encode(errorMessage));
116+
const text = ansiHTML(encode(errorMessage));
118117

119118
div.innerHTML = `<span style="color: #${colors.red}">Failed to compile.</span><br><br>${text}`;
120119
});

lib/Server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ class Server {
752752

753753
const configArr = getCompilerConfigArray(this.compiler);
754754
const statsOption = getStatsOption(configArr);
755+
755756
if (typeof statsOption === 'object' && statsOption.warningsFilter) {
756757
stats.warningsFilter = statsOption.warningsFilter;
757758
}

0 commit comments

Comments
 (0)