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

Core: Fix missing favicon during dev #24356

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions code/lib/core-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
"prompts": "^2.4.0",
"read-pkg-up": "^7.0.1",
"semver": "^7.3.7",
"serve-favicon": "^2.5.0",
"telejson": "^7.2.0",
"tiny-invariant": "^1.3.1",
"ts-dedent": "^2.0.0",
Expand All @@ -108,7 +107,6 @@
"@types/compression": "^1.7.0",
"@types/ip": "^1.1.0",
"@types/node-fetch": "^2.5.7",
"@types/serve-favicon": "^2.5.2",
"@types/ws": "^8",
"boxen": "^5.1.2",
"jest-os-detection": "^1.3.1",
Expand Down
8 changes: 4 additions & 4 deletions code/lib/core-server/src/utils/server-statics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import type { Options, StorybookConfig } from '@storybook/types';
import { getDirectoryFromWorkingDir } from '@storybook/core-common';
import { ConflictingStaticDirConfigError } from '@storybook/core-events/server-errors';
import chalk from 'chalk';
import type { Router } from 'express';
import express from 'express';
import { pathExists } from 'fs-extra';
import path from 'path';
import favicon from 'serve-favicon';
import path, { basename } from 'path';
import isEqual from 'lodash/isEqual.js';

import { dedent } from 'ts-dedent';
import { defaultStaticDirs } from './constants';

export async function useStatics(router: any, options: Options) {
export async function useStatics(router: Router, options: Options) {
const staticDirs =
(await options.presets.apply<StorybookConfig['staticDirs']>('staticDirs')) ?? [];
const faviconPath = await options.presets.apply<string>('favicon');
Expand Down Expand Up @@ -54,7 +54,7 @@ export async function useStatics(router: any, options: Options) {
);
}

router.use(favicon(faviconPath));
router.get(`/${basename(faviconPath)}`, (req, res) => res.sendFile(faviconPath));
}

export const parseStaticDir = async (arg: string) => {
Expand Down
38 changes: 0 additions & 38 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6853,7 +6853,6 @@ __metadata:
"@types/node-fetch": ^2.5.7
"@types/pretty-hrtime": ^1.0.0
"@types/semver": ^7.3.4
"@types/serve-favicon": ^2.5.2
"@types/ws": ^8
better-opn: ^3.0.2
boxen: ^5.1.2
Expand All @@ -6874,7 +6873,6 @@ __metadata:
prompts: ^2.4.0
read-pkg-up: ^7.0.1
semver: ^7.3.7
serve-favicon: ^2.5.0
slash: ^5.0.0
telejson: ^7.2.0
tiny-invariant: ^1.3.1
Expand Down Expand Up @@ -9645,15 +9643,6 @@ __metadata:
languageName: node
linkType: hard

"@types/serve-favicon@npm:^2.5.2":
version: 2.5.4
resolution: "@types/serve-favicon@npm:2.5.4"
dependencies:
"@types/express": "*"
checksum: 60bb648eff8bba7f589e9a2027879c39c137c96e1afafb6a09cb220477c1ebe74c3ce4293c52724592f04e3278950b82741f449c8517a432c163107333a0d6b8
languageName: node
linkType: hard

"@types/serve-index@npm:^1.9.1":
version: 1.9.1
resolution: "@types/serve-index@npm:1.9.1"
Expand Down Expand Up @@ -23671,13 +23660,6 @@ __metadata:
languageName: node
linkType: hard

"ms@npm:2.1.1":
version: 2.1.1
resolution: "ms@npm:2.1.1"
checksum: 056140c631e740369fa21142417aba1bd629ab912334715216c666eb681c8f015c622dd4e38bc1d836b30852b05641331661703af13a0397eb0ca420fc1e75d9
languageName: node
linkType: hard

"ms@npm:2.1.2":
version: 2.1.2
resolution: "ms@npm:2.1.2"
Expand Down Expand Up @@ -28475,13 +28457,6 @@ __metadata:
languageName: node
linkType: hard

"safe-buffer@npm:5.1.1":
version: 5.1.1
resolution: "safe-buffer@npm:5.1.1"
checksum: 1c233bd105deeba3c9a8911ed4ec24ba45adbb51fec02f7944a10a202c38e3df4ef2b524bdeb55f2e4f8c77c13b2959e2e2e6022e5d99acdd70633b5f7e138cf
languageName: node
linkType: hard

"safe-buffer@npm:5.1.2, safe-buffer@npm:~5.1.0, safe-buffer@npm:~5.1.1":
version: 5.1.2
resolution: "safe-buffer@npm:5.1.2"
Expand Down Expand Up @@ -28790,19 +28765,6 @@ __metadata:
languageName: node
linkType: hard

"serve-favicon@npm:^2.5.0":
version: 2.5.0
resolution: "serve-favicon@npm:2.5.0"
dependencies:
etag: ~1.8.1
fresh: 0.5.2
ms: 2.1.1
parseurl: ~1.3.2
safe-buffer: 5.1.1
checksum: 7244ced3c46f8dfde591dc801f1e21ebc8fa07c4870cbbaee3ce37104b3aad32858e674e251a8ed4837867ea0dd67cb734b485ae5a7b0895cb6022f8b8c79303
languageName: node
linkType: hard

"serve-index@npm:^1.9.1":
version: 1.9.1
resolution: "serve-index@npm:1.9.1"
Expand Down
Loading