-
Notifications
You must be signed in to change notification settings - Fork 2
Generate svg config #26
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
Open
Grit03
wants to merge
30
commits into
mash-up-kr:develop
Choose a base branch
from
Grit03:generate-svg-config
base: develop
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.
Open
Conversation
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
ee8bc40 to
489c2fe
Compare
489c2fe to
72f5bbb
Compare
65c63b2 to
4b96dae
Compare
Brightbong92
approved these changes
Oct 24, 2025
Comment on lines
+34
to
+44
| if ( | ||
| (types.namedTypes.Property.check(prop) || | ||
| types.namedTypes.ObjectProperty.check(prop) || | ||
| types.namedTypes.ObjectMethod.check(prop)) && | ||
| ((types.namedTypes.Identifier.check(prop.key) && | ||
| prop.key.name === keyName) || | ||
| (types.namedTypes.Literal.check(prop.key) && | ||
| String(prop.key.value) === keyName)) | ||
| ) { | ||
| return prop; | ||
| } |
Member
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.
조건절이 길다보니 파악이 어려울수 있으니, 의미하는바를 변수나 함수로 바꾸는건 어떻게 생각하나요?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
Next.js와 Vite 프로젝트에서 SVG 파일을 React 컴포넌트로 자동 import 할 수 있도록 설정하기 위해선 여러 파일과 플러그인 설치, 적용이 필요합니다. 해당 내용을 자동화하는
@mash-up-web-toolkit/cli/generate-svg-configCLI 패키지를 구현했습니다.코드 생성을 위해서, 기존 플러그인을 유지해야(비파괴적 수정)할 수 있는데, 이런 처리를 위해 ast 변환 후 코드를 일부분 수정하여 생성하는 방식을 채택했습니다. AST 변환을 위한 라이브러리는 recast를 사용하였습니다.
Package Scope
@mash-up-web-toolkit/cli/generate-svg-config주요 기능
1. 자동 프로젝트 감지 및 설정
package.json의 dependencies를 분석하여 Next.js 또는 Vite 프로젝트 자동 감지2. Next.js 설정 자동화
@svgr/webpack자동 설치svgr.d.ts타입 선언 파일 생성tsconfig.json의 include 배열에 타입 선언 추가3. Vite 설정 자동화
vite-plugin-svgr자동 설치vite.config파일에 svgr 플러그인 자동 추가src/vite-env.d.ts타입 선언 파일 업데이트4. 스마트 Config 파일 처리
다양한 export 패턴 지원:
export default { ... }module.exports = { ... }const config = { ... }; export default configexport default defineConfig(() => ({ ... }))mergeConfig패턴 지원기존 설정 보존:
지원 범위
프레임워크
15.3.0버전 이상, webpack + turbopack설정 파일
next.config.tsvite.config.tsnext.config.jsvite.config.jsnext.config.mjs패키지 매니저
Config 패턴
export default { ... }module.exports = { ... }const config = { ... }; export default configexport default defineConfig({ ... })export default defineConfig(() => ({ ... }))mergeConfig(base, { ... })핵심 파일 구조 더보기
generate-svg-config패키지 파일 구조테스트 환경
apps/svg-config-playground/next-ts: Next.js + TypeScript 테스트용apps/svg-config-playground/vite-react-ts: Vite + React + TypeScript 테스트용apps/my-playground: 실제 동작 테스트 완료Checklist