Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serveIndex: set icons by default. #2440

Closed
jlguenego opened this issue Feb 28, 2020 · 3 comments
Closed

serveIndex: set icons by default. #2440

jlguenego opened this issue Feb 28, 2020 · 3 comments

Comments

@jlguenego
Copy link
Contributor

Change Request :
the serveIndex currently accepts icons. WebpackDevServer would be a nicer app if icons were visible by default.

Yes it is very minor.

@alexander-akait
Copy link
Member

Do you want setup own icons or we should setup default icon?

@jlguenego
Copy link
Contributor Author

Just adding {icons:true} to serveIndex.

Here is the code change I would suggest in the lib/Server.js:

setupServeIndexFeature() {
    const contentBase = this.options.contentBase;
    const contentBasePublicPath = this.options.contentBasePublicPath;

    if (Array.isArray(contentBase)) {
      contentBase.forEach((item) => {
        this.app.use(contentBasePublicPath, (req, res, next) => {
          // serve-index doesn't fallthrough non-get/head request to next middleware
          if (req.method !== 'GET' && req.method !== 'HEAD') {
            return next();
          }

          serveIndex(item, { icons: true })(req, res, next);
        });
      });
    } else if (
      typeof contentBase !== 'number' &&
      !isAbsoluteUrl(String(contentBase))
    ) {
      this.app.use(contentBasePublicPath, (req, res, next) => {
        // serve-index doesn't fallthrough non-get/head request to next middleware
        if (req.method !== 'GET' && req.method !== 'HEAD') {
          return next();
        }

        serveIndex(contentBase, { icons: true })(req, res, next);
      });
    }
  }

@alexander-akait
Copy link
Member

Solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants