Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ssi02014/react-npm-deploy-boilerplate
React Design System Npm Deploy BoilarPlate ๐ป
https://github.com/ssi02014/react-npm-deploy-boilerplate
component npm react rollup storybook styled-components typescript
Last synced: 2 months ago
JSON representation
React Design System Npm Deploy BoilarPlate ๐ป
- Host: GitHub
- URL: https://github.com/ssi02014/react-npm-deploy-boilerplate
- Owner: ssi02014
- Created: 2022-05-20T21:42:36.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-08-23T15:48:29.000Z (over 1 year ago)
- Last Synced: 2024-10-14T06:51:26.411Z (3 months ago)
- Topics: component, npm, react, rollup, storybook, styled-components, typescript
- Language: JavaScript
- Homepage: https://github.com/ssi02014/react-npm-deploy-boilerplate
- Size: 5.15 MB
- Stars: 8
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ป ๋ฆฌ์กํธ ๋์์ธ ์์คํ NPM ๋ฐฐํฌ ๋ณด์ผ๋ฌ ํ๋ ์ดํธ
- UI Kits, Design System ๊ตฌ์ถ์ ์ํ NPM์ผ๋ก ์คํ์์ค ๋ฐฐํฌ์ ์ต์ ํ ๋ณด์ผ๋ฌ ํ๋ ์ดํธ
- `2023๋ 6์ ๊ธฐ์ค` ์ต์ ๋ฒ์ ์ผ๋ก ๊ตฌ์ถ๋์ด ์์ต๋๋ค.
- ์นํฉ ๊ฐ๋ฐ ์๋ฒ, ๋ถ ํ์ํ ํ๋ฌ๊ทธ์ธ, ๋ก๋ ๋ฑ ๋ชจ๋ ์ ๊ฑฐ ํ ๊ฒฝ๋ํ
- ๋ชจ๋ ์ปดํฌ๋ํธ UI ํ ์คํธ๋ ์นํฉ ๊ฐ๋ฐ ์๋ฒ๋ฅผ ๋์ฐ์ง ์๊ณ , `Storybook`์ ์ด์ฉ (ํ๋จ ๋ด์ฉ ์ฐธ๊ณ )
- cjs, esm ๋ชจ๋ ์ง์
## ๐ ๊ตฌ์ฑ
- React v18
- Babel์ ์ด์ฉํ ํธ๋์คํ์ผ๋ง
- Rollup์ ์ด์ฉํ ๋ฒ๋ค๋ง
- TypeScript v5
- @emotion
- Storybook v7
### ์คํ ๋ฆฌ๋ถ ๊นํ๋ธ ํ์ด์ง
- https://ssi02014.github.io/react-npm-deploy-boilerplate/
### ์์กด์ฑ ์ค์น
- ํด๋น ๋ ํฌ๋ `yarn ํจํค์ง ๋งค๋์ `๋ก ๊ตฌ์ฑํ๊ธฐ ๋๋ฌธ์ ํน์ ์ด์๊ฐ ์๋ค๋ฉด yarn์ ์ด์ฉํด ์์กด์ฑ ์ค์น๋ฅผ ๊ถ์ฅ
```
yarn
or
yarn install
```
### package.json ์์
- ํด๋น ๋ณด์ผ๋ฌ ํ๋ ์ดํธ๋ฅผ cloneํด์ ์ฌ์ฉํ๋ค๋ฉด package.json ์์ ์ด ํ์ํจ
- `name`, `version`, `description`, `repository/url`, `author`, `homepage` ... ๋ฑ ์์ ํ์
```json
{
"name": "react-npm-deploy-boilerplate", // (*)
"version": "1.0.0", // (*)
"description": "react-npm-deploy-boilerplate", // (*)
"scripts": {
// ...
},
"repository": {
"type": "git",
"url": "git+https://github.com/ssi02014/react-npm-deploy-boilerplate.git" // (*)
},
"author": "Gromit", // (*)
"license": "ISC",
"bugs": {
"url": "https://github.com/ssi02014/react-npm-deploy-boilerplate.git/issues" // (*)
},
"homepage": "https://github.com/ssi02014/react-dev-env-boilarplate", // (*)
// ...
}```
## ์ปดํฌ๋ํธ ๊ฐ๋ฐ
- `src/components`์์ ์ปดํฌ๋ํธ ์์
```jsx
// src/components/Button/Button.tsx
import React from 'react';
import styled from '@emotion/styled';interface Props {
children: React.ReactNode;
size?: 'medium' | 'large';
}const Button = ({ children, size = 'medium' }: Props) => {
return {children};
};
```- `src/stories/components`์์ `{Component}.stories.tsx` ํํ๋ก ํ์ผ ์์ฑ ํ ์คํ ๋ฆฌ๋ถ์ผ๋ก UI ํ ์คํธ ์งํ
- ์คํ ๋ฆฌ๋ถ์์ UI ํ ์คํธ ์งํ ํ `src/index.tsx`์์ export
```jsx
export { default as theme } from '@shared/theme';
export { default as Button } from '@components/Button';
```
### ์ด๋ฏธ์ง ์ฌ์ฉ
```jsx
import image from '../../assets/sheep.jpg';
import testUrl, { ReactComponent as TestSVG } from '../../assets/test.svg';const Component = ({ children, size = 'medium' }: Props) => {
return (
<>
{/* image test */}
{/* svg component test */}
{/* svg url test */}
>
);
};```
## ๋น๋์ ๋ฐฐํฌ
- ์ปดํฌ๋ํธ ์์ ํ ์๋ ๋ช ๋ น์ด๋ฅผ ํตํด ๋ฐฐํฌ๋ฅผ ์ํ build ์งํ
```
yarn build
```
- build๋ฅผ ์งํํ๋ฉด ์ ์์ ์ผ๋ก `dist` ํด๋๊ฐ ์์ฑ๋์ด์ผ ํ๋ค. ์ค์ง์ ์ผ๋ก ํด๋น ํด๋๋ฅผ npm์ ๋ฐฐํฌํ๊ฒ ๋๋ค.
- ์ฌ์ค ํ์ฌ ์ ์ฅ์๋ `github actions`์ ํตํด ์๋ ๋น๋ ๋ฐ npm ๋ฐฐํฌ๋ฅผ ์งํํ๋ค. ๋ํ, ์คํ ๋ฆฌ๋ถ ํ์ด์ง๋ ์๋ ๋น๋ ํ์ github page๋ก ๋ฐฐํฌ๋ฅผ ์งํํ๋ค.
- ์ ๊ณผ์ ์ `master` ๋ธ๋์น๋ก๋ง ์ปค๋ฐ์ด ์ฌ๋ผ๊ฐ๋ฉด ์ด๋ฅผ ํธ๋ฆฌ๊ฑฐ ์ผ์ ์๋์ผ๋ก ์งํ๋๋ค.
- ๋ฐฐํฌ ์ ์ package.json `version` ์ ๋ฐ์ดํธ ํด์ฃผ๋ ๊ฒ์ ๊ผญ! ์์ง๋ง์.
### npm deploy ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น ๋ฐ ์ฌ์ฉ๋ฒ
```
yarn add (๋ณธ์ธ ๋ฐฐํฌ ์ ์ฅ์)
```
```jsx
import { Button } from 'react-npm-deploy-boilerplate';function App() {
return (
ํ์ด
๋ฐ์ด
)
}export default App;
```
### storybook
- storybook์ ํตํด์ ui ํ ์คํธ๊ฐ ๊ฐ๋ฅํ๋ค.
- ์๋ ๋ช ๋ น์ด๋ฅผ ํฐ๋ฏธ๋๋ก ์ ๋ ฅ์ ํตํด ์คํ ๋ฆฌ๋ถ ์๋ฒ๋ฅผ ์คํํ ์ ์๋ค.
```
yarn storybook
```
- ์๋์ ๊ฐ์ ์์ ์ฝ๋๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์คํ ๋ฆฌ๋ถ ์ฝ๋ ์์ฑ
```jsx
// src/stories/components/Button.stories.tsx
import React from 'react';
import { StoryFn } from '@storybook/react';
import Button from '@components/Button';export default {
title: 'components/Button',
argTypes: {
variant: {
options: ['primary', 'secondary'],
control: { type: 'check' },
},
size: {
options: ['medium', 'large', 'small'],
control: { type: 'select' },
},
},
};interface Props {
size: 'medium' | 'large' | 'small';
select: any[];
}const Template: StoryFn = ({ size }: Props) => {
return (
์๋
);
};export const Default = {
render: Template,args: {
size: 'medium',
},
};// ...
```
### storybook github page ๋ฐฐํฌ
- `build:storybook`์ผ๋ก ๋น๋ ํ์ `deploy:storybook`์ผ๋ก github page๋ก ๋ฐฐํฌ
```
yarn build:storybook
```
```
yarn deploy:storybook
```### rollup alias(์ ๋ ๊ฒฝ๋ก) ์ถ๊ฐํ๋ ๋ฐฉ๋ฒ
```json
// tsconfig.paths.json
{
"compilerOptions": {
"paths": {
"@components/*": ["src/components/*"],
"@shared/*": ["src/shared/*"],
// ์ฌ๊ธฐ๋ค ์ถ๊ฐ
},
}
}
```