Skip to content
Draft
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: 1 addition & 1 deletion app/hooks/useNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const useNotification = () => {
coldStartNotificationOpen();

// FCM 토큰 갱신 리스너: 토큰이 변경되면 자동으로 서버에 업데이트
const unsubscribeTokenRefresh = messaging().onTokenRefresh(async () => {
const unsubscribeTokenRefresh = messaging().onTokenRefresh( async () => {
console.log('FCM 토큰이 갱신되었습니다');
try {
await registerFCMToken();
Expand Down
3,179 changes: 961 additions & 2,218 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

63 changes: 13 additions & 50 deletions web/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1,24 @@
import type { StorybookConfig } from '@storybook/react-webpack5';
import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';
import webpack from 'webpack';
import type { StorybookConfig } from '@storybook/react-vite';
import { mergeConfig } from 'vite';

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: ['@storybook/addon-webpack5-compiler-swc', '@storybook/addon-docs'],
addons: ['@storybook/addon-docs'],
framework: {
name: '@storybook/react-webpack5',
name: '@storybook/react-vite',
options: {},
},
webpackFinal: async (config) => {
config.plugins?.push(
new webpack.EnvironmentPlugin({
API_BASE_URL: 'https://api-dev.bombom.news/api/v1',
API_TOKEN: '',
ENABLE_MSW: 'false',
}),
new webpack.DefinePlugin({
'process.env': JSON.stringify(process.env),
}),
);

const imageRule = config.module?.rules?.find((rule) => {
const test = (rule as { test: RegExp }).test;

if (!test) {
return false;
}

return test.test('.svg');
}) as { [key: string]: any };

imageRule.exclude = /\.svg$/;

config.module?.rules?.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
});

config.module?.rules?.push({
test: /\.(avif|png|jpe?g|gif|svg)$/i,
type: 'asset/resource',
generator: {
filename: 'static/media/[name].[hash][ext]',
viteFinal: async (config) => {
return mergeConfig(config, {
define: {
'process.env.API_BASE_URL': JSON.stringify(
process.env.API_BASE_URL ?? 'https://api-dev.bombom.news/api/v1',
),
'process.env.API_TOKEN': JSON.stringify(process.env.API_TOKEN ?? ''),
'process.env.ENABLE_MSW': JSON.stringify(process.env.ENABLE_MSW ?? 'false'),
},
});

return {
...config,
resolve: {
...config.resolve,
plugins: [
...(config.resolve?.plugins || []),
new TsconfigPathsPlugin({}),
],
},
};
},
Comment on lines +11 to 21

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

부연 설명: webpack 시절 main.ts가 60줄에서 24줄로 줄어든 이유

webpack 버전에서 webpackFinal이 직접 처리하던 세 가지가 vite 버전에서는 다음과 같이 분배됨:

  1. 환경 변수 주입 (process.env.X → 빌드 상수)

    • webpack: webpack.EnvironmentPlugin + webpack.DefinePlugin(JSON.stringify(process.env)) 두 단계
    • vite: viteFinal에서 mergeConfigdefine만 주입. vite의 define은 단순 raw 치환이라 문자열 값에는 JSON.stringify로 따옴표를 직접 감싸야 함 (그래서 JSON.stringify(... ?? '...') 형태). ?? fallback은 storybook 단독 실행(storybook dev) 시 .env가 없는 케이스 대비.
  2. SVG 처리 (*.svg → React component)

    • webpack: imageRule.exclude = /\.svg$/ 로 기존 image rule을 깎고 @svgr/webpack을 새 rule로 추가하는 수동 surgery
    • vite: 메인 web/vite.config.tsvite-plugin-svgr이 처리. @storybook/react-vite가 메인 vite config을 자동 상속하므로 storybook 쪽에서 다시 선언할 필요 없음.
  3. 이미지 자산 처리 (avif/png/jpe?g/gif)

    • webpack: asset/resource rule을 직접 push
    • vite: 빌트인. 별도 설정 불필요.
  4. path alias (@/, #/)

    • webpack: TsconfigPathsPluginresolve.plugins에 주입
    • vite: 메인 vite.config.ts의 alias 설정 + tsconfig를 storybook이 자동 상속.

요약: vite가 빌트인으로 처리하거나(이미지) 메인 config을 상속(SVG/alias)하는 부분이 많아 storybook main.ts는 "환경 변수 주입"만 남음.

};

export default config;
2 changes: 1 addition & 1 deletion web/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Global, ThemeProvider } from '@emotion/react';
import type { Preview, Decorator } from '@storybook/react-webpack5';
import type { Preview, Decorator } from '@storybook/react-vite';
import { theme } from '@bombom/shared/theme';
import {
createRouter,
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,6 @@
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
38 changes: 12 additions & 26 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"name": "@bombom/web",
"private": true,
"version": "1.0.0",
"main": "index.js",
"type": "module",
"scripts": {
"start": "webpack serve --mode development",
"start:msw": "webpack serve --mode development --env ENABLE_MSW=true",
"build": "webpack --mode production",
"start": "vite",
"start:msw": "ENABLE_MSW=true vite",
"build": "vite build",
"preview": "vite preview",
"lint": "eslint src --ext .ts,.tsx,.js,.jsx",
"lint:fix": "eslint src --ext .ts,.tsx,.js,.jsx --fix",
"stylelint:fix": "stylelint './src/**/*.tsx' --fix",
Expand All @@ -33,11 +34,8 @@
"@babel/preset-typescript": "^7.27.1",
"@jest/globals": "^30.0.4",
"@playwright/test": "^1.54.1",
"@storybook/addon-docs": "^9.0.17",
"@storybook/addon-webpack5-compiler-swc": "^3.0.0",
"@storybook/react-webpack5": "^9.0.17",
"@svgr/webpack": "^8.1.0",
"@swc/core": "^1.14.0",
"@storybook/addon-docs": "^9.1.20",
"@storybook/react-vite": "^9.1.20",
"@tanstack/router-plugin": "^1.128.3",
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.3.0",
Expand All @@ -46,14 +44,11 @@
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
"@types/react-google-recaptcha": "^2.1.9",
"@types/webpack": "^5.28.5",
"@typescript-eslint/eslint-plugin": "^8.37.0",
"@typescript-eslint/parser": "^8.36.0",
"@vitejs/plugin-react-swc": "^3.7.2",
"babel-jest": "^30.0.4",
"babel-loader": "^10.0.0",
"chromatic": "^13.1.2",
"copy-webpack-plugin": "^13.0.1",
"css-loader": "^7.1.2",
"dotenv-cli": "^10.0.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^10.1.5",
Expand All @@ -63,24 +58,16 @@
"eslint-plugin-prettier": "^5.5.1",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-storybook": "^9.0.17",
"html-webpack-plugin": "^5.6.3",
"eslint-plugin-storybook": "^9.1.20",
"jest": "^30.0.4",
"jest-environment-jsdom": "^30.0.4",
"msw": "^2.10.4",
"openapi-typescript": "^7.8.0",
"postcss-styled-syntax": "^0.7.1",
"storybook": "^9.0.17",
"style-loader": "^4.0.0",
"swc-loader": "^0.2.6",
"swc-minify-webpack-plugin": "^2.1.3",
"terser-webpack-plugin": "^5.3.14",
"ts-node": "^10.9.2",
"tsconfig-paths-webpack-plugin": "^4.2.0",
"storybook": "^9.1.20",
"typescript": "^5.8.3",
"webpack": "^5.100.0",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.2"
"vite": "^6.0.11",
"vite-plugin-svgr": "^4.3.0"
},
"dependencies": {
"@bombom/shared": "workspace:*",
Expand All @@ -92,7 +79,6 @@
"@tanstack/react-query": "^5.82.0",
"@tanstack/react-router": "^1.128.3",
"@tanstack/react-router-devtools": "^1.128.3",
"dotenv": "^17.2.0",
"html2canvas": "^1.4.1",
"react": "^19.1.0",
"react-dom": "^19.1.0",
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Badge from './Badge';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta = {
title: 'components/common/Badge',
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Carousel/Carousel.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTheme } from '@emotion/react';
import { Carousel } from './Carousel';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta = {
title: 'components/common/Carousel',
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Chip/Chip.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Chip from './Chip';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta = {
title: 'components/common/Chip',
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Flex/Flex.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Flex from './Flex';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta = {
title: 'components/common/Flex',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { theme } from '@bombom/shared/theme';
import styled from '@emotion/styled';
import FloatingActionButton from './FloatingActionButton';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';
import BookmarkIcon from '#/assets/svg/bookmark-inactive.svg';
import CommentIcon from '#/assets/svg/comment.svg';
import LinkIcon from '#/assets/svg/link.svg';
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Header/Header.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PCHeader from './PCHeader';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta: Meta<typeof PCHeader> = {
title: 'components/common/PCHeader',
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/ImageInfoCard/ImageInfoCard.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ImageInfoCard from './ImageInfoCard';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta: Meta<typeof ImageInfoCard> = {
title: 'components/common/ImageInfoCard',
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Pagination/Pagination.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react';
import Pagination from './Pagination';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta: Meta<typeof Pagination> = {
title: 'Components/common/Pagination',
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/ProgressBar/ProgressBar.stories.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ProgressBar from './ProgressBar';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta = {
title: 'components/common/ProgressBar',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ProgressWithLabel from './ProgressWithLabel';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';
import CompassIcon from '#/assets/svg/compass.svg';

const meta = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import RequireLoginCard from './RequireLoginCard';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta = {
title: 'components/common/RequireLoginCard',
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/SearchInput/SearchInput.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SearchInput from './SearchInput';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta: Meta<typeof SearchInput> = {
title: 'components/common/SearchInput',
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Select/Select.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react';
import Select from './Select';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta: Meta<typeof Select> = {
title: 'components/common/Select',
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Tab/Tab.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Tab from './Tab';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';
import CompassIcon from '#/assets/svg/compass.svg';

const meta = {
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Tabs/Tabs.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Tabs from './Tabs';
import Tab from '../Tab/Tab';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta = {
title: 'components/common/Tabs',
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Text/Text.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Text from './Text';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta = {
title: 'components/common/Text',
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Toast/Toast.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Toast from './Toast';
import Button from '../Button/Button';
import { toast } from './utils/toastActions';
import type { ToastPosition } from './Toast.types';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

type StoryArgs = {
position?: ToastPosition;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import NewsletterItemCard from './NewsletterItemCard';
import { ARTICLES } from '@/mocks/datas/articles';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta: Meta<typeof NewsletterItemCard> = {
title: 'components/bombom/NewsletterItemCard',
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/login/components/LoginCard.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import LoginCard from './LoginCard';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta = {
title: 'components/bombom/LoginCard',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NewsletterHero from './NewsletterHero';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta: Meta<typeof NewsletterHero> = {
title: 'components/bombom/NewsletterHero',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ReadingKingLeaderboard from './ReadingKingLeaderboard';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta: Meta<typeof ReadingKingLeaderboard> = {
title: 'components/bombom/ReadingKingLeaderboard',
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/signup/components/SignupCard.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SignupCard from './SignupCard';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta = {
title: 'components/bombom/SignupCard',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NewsletterFilter from './NewsletterFilter';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta = {
title: 'components/bombom/NewsletterFilter',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ArticleCard from './ArticleCard';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta = {
title: 'components/bombom/ArticleCard',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ReadingStatusCard from './ReadingStatusCard';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import type { Meta, StoryObj } from '@storybook/react-vite';

const meta = {
title: 'components/bombom/ReadingStatusCard',
Expand Down
6 changes: 3 additions & 3 deletions web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"extends": "../tsconfig.base.json",
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"target": "es6",
"module": "nodenext",
"target": "es2020",
"module": "esnext",
"esModuleInterop": true,
"noUncheckedIndexedAccess": true,
"moduleResolution": "nodenext",
"moduleResolution": "bundler",
"allowUmdGlobalAccess": true,
"types": ["./emotion.d.ts", "jest", "node"],
"paths": {
Expand Down
Loading
Loading