Skip to content

Commit 7200d31

Browse files
fix: schema for the host option (#3549)
1 parent 0c07404 commit 7200d31

File tree

4 files changed

+48
-18
lines changed

4 files changed

+48
-18
lines changed

bin/cli-flags.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,17 @@ module.exports = {
349349
host: {
350350
configs: [
351351
{
352-
type: "string",
352+
description: "Allows to specify a hostname to use.",
353353
multiple: false,
354+
path: "host",
355+
type: "enum",
356+
values: ["local-ip", "local-ipv4", "local-ipv6"],
357+
},
358+
{
354359
description: "Allows to specify a hostname to use.",
360+
multiple: false,
355361
path: "host",
362+
type: "string",
356363
},
357364
],
358365
description: "Allows to specify a hostname to use.",

lib/options.json

+10-3
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,17 @@
283283
"link": "https://webpack.js.org/configuration/dev-server/#devserverhistoryapifallback"
284284
},
285285
"Host": {
286-
"type": "string",
287-
"minLength": 1,
288286
"description": "Allows to specify a hostname to use.",
289-
"link": "https://webpack.js.org/configuration/dev-server/#devserverhost"
287+
"link": "https://webpack.js.org/configuration/dev-server/#devserverhost",
288+
"anyOf": [
289+
{
290+
"enum": ["local-ip", "local-ipv4", "local-ipv6"]
291+
},
292+
{
293+
"type": "string",
294+
"minLength": 1
295+
}
296+
]
290297
},
291298
"Hot": {
292299
"anyOf": [

test/__snapshots__/validate-options.test.js.snap.webpack4

+15-7
Original file line numberDiff line numberDiff line change
@@ -258,23 +258,31 @@ exports[`options validate should throw an error on the "historyApiFallback" opti
258258

259259
exports[`options validate should throw an error on the "host" option with '' value 1`] = `
260260
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
261-
- options.host should be a non-empty string.
262-
-> Allows to specify a hostname to use.
263-
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverhost"
261+
- options.host should be a non-empty string."
264262
`;
265263

266264
exports[`options validate should throw an error on the "host" option with 'false' value 1`] = `
267265
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
268-
- options.host should be a non-empty string.
266+
- options.host should be one of these:
267+
\\"local-ip\\" | \\"local-ipv4\\" | \\"local-ipv6\\" | non-empty string
269268
-> Allows to specify a hostname to use.
270-
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverhost"
269+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverhost
270+
Details:
271+
* options.host should be one of these:
272+
\\"local-ip\\" | \\"local-ipv4\\" | \\"local-ipv6\\"
273+
* options.host should be a non-empty string."
271274
`;
272275

273276
exports[`options validate should throw an error on the "host" option with 'null' value 1`] = `
274277
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
275-
- options.host should be a non-empty string.
278+
- options.host should be one of these:
279+
\\"local-ip\\" | \\"local-ipv4\\" | \\"local-ipv6\\" | non-empty string
276280
-> Allows to specify a hostname to use.
277-
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverhost"
281+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverhost
282+
Details:
283+
* options.host should be one of these:
284+
\\"local-ip\\" | \\"local-ipv4\\" | \\"local-ipv6\\"
285+
* options.host should be a non-empty string."
278286
`;
279287

280288
exports[`options validate should throw an error on the "hot" option with '' value 1`] = `

test/__snapshots__/validate-options.test.js.snap.webpack5

+15-7
Original file line numberDiff line numberDiff line change
@@ -258,23 +258,31 @@ exports[`options validate should throw an error on the "historyApiFallback" opti
258258

259259
exports[`options validate should throw an error on the "host" option with '' value 1`] = `
260260
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
261-
- options.host should be a non-empty string.
262-
-> Allows to specify a hostname to use.
263-
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverhost"
261+
- options.host should be a non-empty string."
264262
`;
265263

266264
exports[`options validate should throw an error on the "host" option with 'false' value 1`] = `
267265
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
268-
- options.host should be a non-empty string.
266+
- options.host should be one of these:
267+
\\"local-ip\\" | \\"local-ipv4\\" | \\"local-ipv6\\" | non-empty string
269268
-> Allows to specify a hostname to use.
270-
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverhost"
269+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverhost
270+
Details:
271+
* options.host should be one of these:
272+
\\"local-ip\\" | \\"local-ipv4\\" | \\"local-ipv6\\"
273+
* options.host should be a non-empty string."
271274
`;
272275

273276
exports[`options validate should throw an error on the "host" option with 'null' value 1`] = `
274277
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
275-
- options.host should be a non-empty string.
278+
- options.host should be one of these:
279+
\\"local-ip\\" | \\"local-ipv4\\" | \\"local-ipv6\\" | non-empty string
276280
-> Allows to specify a hostname to use.
277-
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverhost"
281+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverhost
282+
Details:
283+
* options.host should be one of these:
284+
\\"local-ip\\" | \\"local-ipv4\\" | \\"local-ipv6\\"
285+
* options.host should be a non-empty string."
278286
`;
279287

280288
exports[`options validate should throw an error on the "hot" option with '' value 1`] = `

0 commit comments

Comments
 (0)