Skip to content

Commit 281401f

Browse files
Merge pull request #8 from klmhyeonwoo/chore/build-setup
feat: 라이브러리 빌드 설정
2 parents 5b1b7bf + 2f7bfaa commit 281401f

39 files changed

+6421
-1653
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
"plugin:react/recommended",
1111
"plugin:import/recommended",
1212
"prettier",
13+
"plugin:storybook/recommended"
1314
],
1415
parser: "@typescript-eslint/parser",
1516
parserOptions: {

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
*storybook.log
27+
storybook-static

.storybook/main.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { StorybookConfig } from "@storybook/react-vite";
2+
3+
const config: StorybookConfig = {
4+
stories: ["../packages/**/*.mdx", "../packages/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
5+
addons: [
6+
"@storybook/addon-onboarding",
7+
"@storybook/addon-essentials",
8+
"@chromatic-com/storybook",
9+
"@storybook/addon-interactions",
10+
"@storybook/addon-storysource",
11+
],
12+
framework: {
13+
name: "@storybook/react-vite",
14+
options: {
15+
strictMode: true,
16+
},
17+
},
18+
};
19+
export default config;

.storybook/preview.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { Preview } from "@storybook/react";
2+
3+
const preview: Preview = {};
4+
5+
export default preview;

build.mjs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { globSync } from "glob";
2+
import * as vite from "vite";
3+
import * as tsup from "tsup";
4+
import dts from "vite-plugin-dts";
5+
6+
async function build(path) {
7+
const file = `${path}/src/index.ts`;
8+
const dist = `${path}/dist`;
9+
10+
/**
11+
* @type {import("vite").InlineConfig}
12+
*/
13+
const viteConfig = {
14+
build: {
15+
lib: {
16+
entry: file,
17+
formats: ["es", "cjs"],
18+
fileName: (format) => {
19+
return format === "es" ? "index.mjs" : "index.js";
20+
},
21+
},
22+
ssr: true,
23+
outDir: dist,
24+
rollupOptions: {},
25+
},
26+
plugins: [
27+
dts({
28+
entryRoot: file,
29+
outDir: dist,
30+
}),
31+
],
32+
};
33+
34+
await vite.build(viteConfig);
35+
36+
await tsup.build({
37+
entry: [file],
38+
format: ["cjs", "esm"],
39+
dts: { only: true },
40+
outDir: dist,
41+
silent: true,
42+
external: [/@layer-ui\/.+/],
43+
tsconfig: "./tsconfig.json",
44+
});
45+
46+
console.log(`Built ${path}/dist with Vite`);
47+
}
48+
49+
globSync("packages/*/*").forEach(build);

demo/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

demo/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Layer Design System - Demo
2+
3+
## 소개
4+
5+
- 프로젝트 개요
6+
- 기술 스택 (React + TypeScript + Vite)
7+
8+
## 시작하기
9+
10+
- 설치 방법
11+
- 개발 환경 설정
12+
13+
## 빌드 설정
14+
15+
- 빌드 프로세스 설명
16+
- 환경 변수 설정
17+
18+
## Storybook
19+
20+
- Storybook 설정 방법
21+
- 스토리 작성 가이드
22+
23+
## 개발 가이드라인
24+
25+
- 컴포넌트 개발 프로세스
26+
- 코드 스타일 가이드

index.html renamed to demo/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
56
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
67
<title>Vite + React + TS</title>
78
</head>

demo/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "demo",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc -b && vite build",
9+
"lint": "eslint .",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"react": "^18.3.1",
14+
"react-dom": "^18.3.1"
15+
},
16+
"devDependencies": {
17+
"@eslint/js": "^9.13.0",
18+
"@types/react": "^18.3.12",
19+
"@types/react-dom": "^18.3.1",
20+
"@vitejs/plugin-react": "^4.3.3",
21+
"eslint": "^9.13.0",
22+
"eslint-plugin-react-hooks": "^5.0.0",
23+
"eslint-plugin-react-refresh": "^0.4.14",
24+
"globals": "^15.11.0",
25+
"typescript": "~5.6.2",
26+
"typescript-eslint": "^8.11.0",
27+
"vite": "^5.4.10"
28+
}
29+
}

demo/public/vite.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)