-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: web 패키지 빌드 도구를 webpack에서 vite로 전환 #211
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
Draft
jaeyoung-kwon
wants to merge
6
commits into
dev
Choose a base branch
from
refactor/web-webpack-to-vite
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6407dd5
hotfix: ios일때 알림 설정 페이지로 접근하지 못하도록 수정
JeLee-river 7746eee
refactor: web 앱 빌드를 webpack에서 vite로 전환
JeLee-river b14c22f
refactor: web Storybook을 webpack5에서 vite 빌더로 전환
138d1e9
chore: pnpm i
jaeyoung-kwon e05ed16
chore: 코드 롤백
jaeyoung-kwon 64622ca
chore: vite 전환에서 함께 묻어 들어간 무관한 변경 복원
jaeyoung-kwon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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({}), | ||
| ], | ||
| }, | ||
| }; | ||
| }, | ||
| }; | ||
|
|
||
| export default config; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,5 +86,6 @@ | |
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="/src/main.tsx"></script> | ||
| </body> | ||
| </html> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
web/src/components/FloatingActionButton/FloatingActionButton.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
web/src/components/ProgressWithLabel/ProgressWithLabel.stories.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
web/src/components/RequireLoginCard/RequireLoginCard.stories.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
web/src/pages/detail/components/NewsletterItemCard/NewsletterItemCard.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
web/src/pages/recommend/components/NewsletterHero/NewsletterHero.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
web/src/pages/recommend/components/ReadingKingLeaderboard/ReadingKingLeaderboard.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
web/src/pages/storage/components/NewsletterFilter/NewsletterFilter.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
web/src/pages/today/components/ArticleCard/ArticleCard.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
web/src/pages/today/components/ReadingStatusCard/ReadingStatusCard.stories.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 버전에서는 다음과 같이 분배됨:환경 변수 주입 (
process.env.X→ 빌드 상수)webpack.EnvironmentPlugin+webpack.DefinePlugin(JSON.stringify(process.env))두 단계viteFinal에서mergeConfig로define만 주입. vite의define은 단순 raw 치환이라 문자열 값에는JSON.stringify로 따옴표를 직접 감싸야 함 (그래서JSON.stringify(... ?? '...')형태).??fallback은 storybook 단독 실행(storybook dev) 시 .env가 없는 케이스 대비.SVG 처리 (
*.svg→ React component)imageRule.exclude = /\.svg$/로 기존 image rule을 깎고@svgr/webpack을 새 rule로 추가하는 수동 surgeryweb/vite.config.ts의vite-plugin-svgr이 처리.@storybook/react-vite가 메인 vite config을 자동 상속하므로 storybook 쪽에서 다시 선언할 필요 없음.이미지 자산 처리 (
avif/png/jpe?g/gif)asset/resourcerule을 직접 pushpath alias (
@/,#/)TsconfigPathsPlugin을resolve.plugins에 주입vite.config.ts의 alias 설정 + tsconfig를 storybook이 자동 상속.요약: vite가 빌트인으로 처리하거나(이미지) 메인 config을 상속(SVG/alias)하는 부분이 많아 storybook main.ts는 "환경 변수 주입"만 남음.