diff --git a/src/server/index.js b/src/server/index.js index 14e5f9dd4fec..be08194add7a 100755 --- a/src/server/index.js +++ b/src/server/index.js @@ -66,7 +66,8 @@ if (program.host) { } const app = express(); -app.use(favicon(path.resolve(__dirname, 'public/favicon.ico'))); + +let hasCustomFavicon = false; if (program.staticDir) { program.staticDir = parseList(program.staticDir); @@ -78,9 +79,19 @@ if (program.staticDir) { } logger.log(`=> Loading static files from: ${staticPath} .`); app.use(express.static(staticPath, { index: false })); + + const faviconPath = path.resolve(staticPath, 'favicon.ico'); + if (fs.existsSync(faviconPath)) { + hasCustomFavicon = true; + app.use(favicon(faviconPath)); + } }); } +if (!hasCustomFavicon) { + app.use(favicon(path.resolve(__dirname, 'public/favicon.ico'))); +} + // Build the webpack configuration using the `baseConfig` // custom `.babelrc` file and `webpack.config.js` files const configDir = program.configDir || './.storybook';