Skip to content

Commit

Permalink
Fix usage of custom favicon (#592)
Browse files Browse the repository at this point in the history
* Fix usage of custom favicon

* More explicitly determine if a custom favicon is being served
  • Loading branch information
jeffcarbs authored and arunoda committed Nov 3, 2016
1 parent d6045ef commit 2659293
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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';
Expand Down

0 comments on commit 2659293

Please sign in to comment.