Skip to content

Commit 6e0e653

Browse files
authored
fix: output description for static options (#3246)
1 parent e2b43b8 commit 6e0e653

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

lib/options.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"properties": {
88
"directory": {
99
"type": "string",
10-
"minLength": 1
10+
"minLength": 1,
11+
"description": "Directory for static contents."
1112
},
1213
"staticOptions": {
1314
"type": "object",
@@ -48,9 +49,11 @@
4849
"type": "boolean"
4950
},
5051
{
51-
"type": "object"
52+
"type": "object",
53+
"description": "options for watch, you can find at https://github.com/paulmillr/chokidar"
5254
}
53-
]
55+
],
56+
"description": "Watch for files in static content directory."
5457
}
5558
}
5659
},

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,12 @@ exports[`options validate should throw an error on the "static" option with '' v
308308
- configuration.static should be an non-empty string."
309309
`;
310310

311+
exports[`options validate should throw an error on the "static" option with '{"directory":false}' value 1`] = `
312+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
313+
- configuration.static.directory should be a non-empty string.
314+
-> Directory for static contents."
315+
`;
316+
311317
exports[`options validate should throw an error on the "static" option with '{"publicPath":false}' value 1`] = `
312318
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
313319
- configuration.static should be one of these:
@@ -338,6 +344,22 @@ exports[`options validate should throw an error on the "static" option with '{"s
338344
object { … }"
339345
`;
340346

347+
exports[`options validate should throw an error on the "static" option with '{"watch":10}' value 1`] = `
348+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
349+
- configuration.static should be one of these:
350+
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
351+
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
352+
Details:
353+
* configuration.static.watch should be one of these:
354+
boolean | object { … }
355+
-> Watch for files in static content directory.
356+
Details:
357+
* configuration.static.watch should be a boolean.
358+
* configuration.static.watch should be an object:
359+
object { … }
360+
-> options for watch, you can find at https://github.com/paulmillr/chokidar"
361+
`;
362+
341363
exports[`options validate should throw an error on the "static" option with '0' value 1`] = `
342364
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
343365
- configuration.static should be one of these:

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,12 @@ exports[`options validate should throw an error on the "static" option with '' v
308308
- configuration.static should be an non-empty string."
309309
`;
310310

311+
exports[`options validate should throw an error on the "static" option with '{"directory":false}' value 1`] = `
312+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
313+
- configuration.static.directory should be a non-empty string.
314+
-> Directory for static contents."
315+
`;
316+
311317
exports[`options validate should throw an error on the "static" option with '{"publicPath":false}' value 1`] = `
312318
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
313319
- configuration.static should be one of these:
@@ -338,6 +344,22 @@ exports[`options validate should throw an error on the "static" option with '{"s
338344
object { … }"
339345
`;
340346

347+
exports[`options validate should throw an error on the "static" option with '{"watch":10}' value 1`] = `
348+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
349+
- configuration.static should be one of these:
350+
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
351+
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
352+
Details:
353+
* configuration.static.watch should be one of these:
354+
boolean | object { … }
355+
-> Watch for files in static content directory.
356+
Details:
357+
* configuration.static.watch should be a boolean.
358+
* configuration.static.watch should be an object:
359+
object { … }
360+
-> options for watch, you can find at https://github.com/paulmillr/chokidar"
361+
`;
362+
341363
exports[`options validate should throw an error on the "static" option with '0' value 1`] = `
342364
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
343365
- configuration.static should be one of these:

test/validate-options.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@ const tests = {
277277
{
278278
serveIndex: 'true',
279279
},
280+
{
281+
directory: false,
282+
},
283+
{
284+
watch: 10,
285+
},
280286
],
281287
},
282288
transportMode: {

0 commit comments

Comments
 (0)