message: fix: add favicon middleware back
diff: @@ -14,13 +14,12 @@ const FAVICON_FILES = [
  ];
  function getFaviconFile(p: string): string | undefined {
  - const componentFile = FAVICON_FILES.find((f) => existsSync(join(p, f)));
  - return componentFile;
  + return FAVICON_FILES.find((f) => existsSync(join(p, f)));
  }
  export default (api: IApi) => {
  - if (api.userConfig.favicon) return;
  api.modifyAppData(async (memo) => {
  + if (api.config.favicon) return memo;
  const faviconFile = getFaviconFile(api.paths.absSrcPath);
  if (faviconFile) {
  memo.faviconFile = faviconFile;
  @@ -28,36 +27,30 @@ export default (api: IApi) => {
  return memo;
  });
  - // TODO: add this back
  - // api.addMiddlewares({
  - // fn: () => {
  - // if (api.appData.faviconFile) {
  - // const faviconMiddleware: RequestHandler = (req, res, next) => {
  - // if (req.path === `/${api.appData.faviconFile}`) {
  - // res.sendFile(join(api.paths.absSrcPath, api.appData.faviconFile));
  - // } else {
  - // next();
  - // }
  - // };
  - // return faviconMiddleware as any;
  - // }
  - // },
  - // });
  + api.addMiddlewares(() => [
  + (req, res, next) => {
  + if (
  + api.appData.faviconFile &&
  + req.path === `/${api.appData.faviconFile}`
  + ) {
  + res.sendFile(join(api.paths.absSrcPath, api.appData.faviconFile));
  + } else {
  + next();
  + }
  + },
  + ]);
  api.onBuildComplete(({ err }) => {
  - if (!err) {
  + if (err) return;
  if (api.appData.faviconFile) {
  copyFileSync(
  join(api.paths.absSrcPath, api.appData.faviconFile),
  join(api.paths.absOutputPath, api.appData.faviconFile),
  );
  }
  - }
  });
  - api.modifyHTMLFavicon(() => {
  - if (api.appData.faviconFile) {
  - return api.appData.faviconFile;
  - }
  + api.modifyHTMLFavicon((memo) => {
  + return api.appData.faviconFile || memo;
  });
  };
  