Add library build for package distribution

Add a separate Vite library build (vite.lib.config.ts + `build:lib`) that
bundles src/index.ts to ESM with React/react-dom externalised and the 97
internal `@/` imports resolved at build time, plus type declarations and
copies of tokens.css / typography.css into dist. Point package.json
exports/main/types at dist and make react a peer dependency, so ADS can be
consumed as an installed package (@geljic/ads3-design-system) rather than a
file: + `@/` alias dependency.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-05 12:44:26 +10:00
parent 1c87e23e5d
commit 69751eb6f2
3 changed files with 731 additions and 12 deletions

View File

@@ -3,15 +3,24 @@
"private": true,
"version": "0.1.0",
"type": "module",
"main": "./src/index.ts",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/src/index.d.ts",
"files": [
"dist"
],
"exports": {
".": "./src/index.ts",
"./tokens": "./src/tokens/tokens.css",
"./utils": "./src/lib/utils.ts"
".": {
"types": "./dist/src/index.d.ts",
"import": "./dist/index.js"
},
"./tokens": "./dist/tokens.css",
"./typography": "./dist/typography.css"
},
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"build:lib": "vite build --config vite.lib.config.ts && cp src/tokens/tokens.css src/styles/typography.css dist/",
"lint": "eslint .",
"preview": "vite preview",
"storybook": "storybook dev -p 6006",
@@ -26,14 +35,13 @@
"@fontsource-variable/public-sans": "^5.2.7",
"@tailwindcss/vite": "^4.3.0",
"clsx": "^2.1.1",
"react": "^19.2.6",
"react-dom": "^19.2.6",
"tailwind-merge": "^3.6.0",
"tailwindcss": "^4.3.0"
},
"devDependencies": {
"@chromatic-com/storybook": "^5.2.1",
"@eslint/js": "^10.0.1",
"@microsoft/api-extractor": "^7.58.7",
"@storybook/addon-a11y": "^10.4.0",
"@storybook/addon-designs": "^11.1.3",
"@storybook/addon-docs": "^10.4.0",
@@ -60,6 +68,7 @@
"typescript": "~6.0.2",
"typescript-eslint": "^8.59.2",
"vite": "^8.0.12",
"vite-plugin-dts": "^5.0.2",
"vitest": "^4.1.6"
}
}