Skip to content

Commit 3a0ef7a

Browse files
committed
FIX: 스토리북 프로덕션 환경에서 Next.js Image 컴포넌트를 일반 img 태그로 대체
1 parent 81381f7 commit 3a0ef7a

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

.github/workflows/deploy-storybook.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,6 @@ jobs:
5959
env:
6060
CI: true
6161

62-
- name: Debug - List built files
63-
run: |
64-
echo "=== Storybook static files ==="
65-
find storybook-static -name "*.svg" | head -10
66-
echo "=== Directory structure ==="
67-
ls -la storybook-static/
68-
echo "=== HTML content check ==="
69-
grep -n "chevron-down" storybook-static/index.html || echo "chevron-down not found in index.html"
70-
echo "=== Check if base path is set ==="
71-
grep -n "DDD-12-GROWIT-FE" storybook-static/index.html || echo "Base path not found in HTML"
72-
7362
- name: Setup Pages
7463
uses: actions/configure-pages@v4
7564

.storybook/main.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ const config = {
66
name: '@storybook/nextjs',
77
options: {},
88
},
9-
images: {
10-
unoptimized: true,
11-
},
129
staticDirs: ['../public'],
13-
...(process.env.CI && {
14-
base: '/DDD-12-GROWIT-FE/',
15-
}),
1610
};
1711
export default config;

.storybook/preview.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
import '../src/app/globals.css';
2+
import * as NextImage from 'next/image';
3+
4+
// Next.js Image 컴포넌트를 일반 img 태그로 대체
5+
const OriginalNextImage = NextImage.default;
6+
7+
Object.defineProperty(NextImage, 'default', {
8+
configurable: true,
9+
value: props => {
10+
if (typeof props.src === 'string') {
11+
// GitHub Pages 배포시 base path 추가
12+
const basePath = process.env.NODE_ENV === 'production' ? '/DDD-12-GROWIT-FE' : '';
13+
const src = props.src.startsWith('/') ? `${basePath}${props.src}` : props.src;
14+
15+
return <img {...props} src={src} alt={props.alt || ''} />;
16+
}
17+
return <OriginalNextImage {...props} />;
18+
},
19+
});
220

321
export const parameters = {
422
actions: { argTypesRegex: '^on[A-Z].*' },

0 commit comments

Comments
 (0)