Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class Server {
this.clientOverlay = options.overlay;
this.clientLogLevel = options.clientLogLevel;

this.serveIndex = options.serveIndex;

this.publicHost = options.public;
this.allowedHosts = options.allowedHosts;
this.disableHostCheck = !!options.disableHostCheck;
Expand Down Expand Up @@ -551,7 +553,10 @@ class Server {

defaultFeatures.push('magicHtml');

if (contentBase !== false) {
if (
contentBase !== false &&
(options.serveIndex || options.serveIndex === undefined)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just simplify:

const shouldHandleServeIndex = contentBase || options.serveIndex

serveIndex by default should be true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evilebottnawi i've simplified the condition & i added a comment to elaborate why i'm comparing with undefined

          if (contentBase !== false) {
    // checking if it's set to true or not set (Default : undefined => true)
    options.serveIndex = options.serveIndex || options.serveIndex === undefined;

    const shouldHandleServeIndex = contentBase && options.serveIndex;

    if (shouldHandleServeIndex) {
      defaultFeatures.push('contentBaseIndex');
    }

) {
defaultFeatures.push('contentBaseIndex');
}
// compress is placed last and uses unshift so that it will be the first middleware used
Expand Down
3 changes: 3 additions & 0 deletions lib/options.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"type": "object",
"properties": {
"serveIndex": {
"type": "boolean"
},
"hot": {
"type": "boolean"
},
Expand Down