File tree Expand file tree Collapse file tree 3 files changed +83
-4
lines changed Expand file tree Collapse file tree 3 files changed +83
-4
lines changed Original file line number Diff line number Diff line change @@ -863,13 +863,20 @@ class Server {
863
863
? optionsForStatic . publicPath
864
864
: [ optionsForStatic . publicPath ]
865
865
: def . publicPath ,
866
- // TODO: do merge in the next major release
867
866
serveIndex :
867
+ // Check if 'serveIndex' property is defined in 'optionsForStatic'
868
+ // If 'serveIndex' is a boolean and true, use default 'serveIndex'
869
+ // If 'serveIndex' is an object, merge its properties with default 'serveIndex'
870
+ // If 'serveIndex' is neither a boolean true nor an object, use it as-is
871
+ // If 'serveIndex' is not defined in 'optionsForStatic', use default 'serveIndex'
868
872
// eslint-disable-next-line no-nested-ternary
869
873
typeof optionsForStatic . serveIndex !== "undefined"
870
- ? typeof optionsForStatic . serveIndex === "boolean" &&
874
+ ? // eslint-disable-next-line no-nested-ternary
875
+ typeof optionsForStatic . serveIndex === "boolean" &&
871
876
optionsForStatic . serveIndex
872
877
? def . serveIndex
878
+ : typeof optionsForStatic . serveIndex === "object"
879
+ ? { ...def . serveIndex , ...optionsForStatic . serveIndex }
873
880
: optionsForStatic . serveIndex
874
881
: def . serveIndex ,
875
882
watch :
Original file line number Diff line number Diff line change @@ -2363,7 +2363,66 @@ exports[`normalize options static publicPath is an array 1`] = `
2363
2363
}
2364
2364
`;
2365
2365
2366
- exports[`normalize options static serveIndex is an object 1`] = `
2366
+ exports[`normalize options static serveIndex is an object more options 1`] = `
2367
+ {
2368
+ "allowedHosts": "auto",
2369
+ "bonjour": false,
2370
+ "client": {
2371
+ "logging": "info",
2372
+ "overlay": true,
2373
+ "reconnect": 10,
2374
+ "webSocketURL": {},
2375
+ },
2376
+ "compress": true,
2377
+ "devMiddleware": {},
2378
+ "historyApiFallback": false,
2379
+ "host": undefined,
2380
+ "hot": true,
2381
+ "liveReload": true,
2382
+ "open": [],
2383
+ "port": "<auto>",
2384
+ "server": {
2385
+ "options": {},
2386
+ "type": "http",
2387
+ },
2388
+ "setupExitSignals": true,
2389
+ "static": [
2390
+ {
2391
+ "directory": "<cwd>/public",
2392
+ "publicPath": [
2393
+ "/",
2394
+ ],
2395
+ "serveIndex": {
2396
+ "hidden": true,
2397
+ "icons": true,
2398
+ "stylesheet": "https://example.com/style.css",
2399
+ "view": "details",
2400
+ },
2401
+ "staticOptions": {},
2402
+ "watch": {
2403
+ "alwaysStat": true,
2404
+ "atomic": false,
2405
+ "followSymlinks": false,
2406
+ "ignoreInitial": true,
2407
+ "ignorePermissionErrors": true,
2408
+ "ignored": undefined,
2409
+ "interval": undefined,
2410
+ "persistent": true,
2411
+ "usePolling": false,
2412
+ },
2413
+ },
2414
+ ],
2415
+ "watchFiles": [],
2416
+ "webSocketServer": {
2417
+ "options": {
2418
+ "path": "/ws",
2419
+ },
2420
+ "type": "ws",
2421
+ },
2422
+ }
2423
+ `;
2424
+
2425
+ exports[`normalize options static serveIndex is an object with icons false 1`] = `
2367
2426
{
2368
2427
"allowedHosts": "auto",
2369
2428
"bonjour": false,
Original file line number Diff line number Diff line change @@ -469,7 +469,7 @@ describe("normalize options", () => {
469
469
} ,
470
470
} ,
471
471
{
472
- title : "static serveIndex is an object" ,
472
+ title : "static serveIndex is an object with icons false " ,
473
473
multiCompiler : false ,
474
474
options : {
475
475
static : {
@@ -479,6 +479,19 @@ describe("normalize options", () => {
479
479
} ,
480
480
} ,
481
481
} ,
482
+ {
483
+ title : "static serveIndex is an object more options" ,
484
+ multiCompiler : false ,
485
+ options : {
486
+ static : {
487
+ serveIndex : {
488
+ hidden : true ,
489
+ stylesheet : "https://example.com/style.css" ,
490
+ view : "details" ,
491
+ } ,
492
+ } ,
493
+ } ,
494
+ } ,
482
495
483
496
{
484
497
title : "single compiler watchOptions is object" ,
You can’t perform that action at this time.
0 commit comments