Skip to content

Commit 77dbcc7

Browse files
committed
chore: vite-build-setup
1 parent 3654447 commit 77dbcc7

File tree

4 files changed

+593
-25
lines changed

4 files changed

+593
-25
lines changed

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
"version": "2.20.0",
44
"description": "UI components library which implements the Kleros design system.",
55
"source": "src/lib/index.ts",
6-
"main": "dist/index.js",
7-
"types": "dist/types.d.ts",
6+
"main": "dist/ui-components-library.umd.cjs",
7+
"module": "dist/ui-components-library.js",
8+
"types": "dist/ui-components-library.d.ts",
9+
"style": "dist/ui-components-library.css",
810
"isLibrary": true,
911
"type": "module",
1012
"browserslist": "> 0.5%, last 2 versions, not dead",
@@ -94,7 +96,8 @@
9496
"smooth-scroll-into-view-if-needed": "^1.1.33",
9597
"tailwind-merge": "^3.0.2",
9698
"tailwindcss-react-aria-components": "^2.0.0",
97-
"usehooks-ts": "^2.9.1"
99+
"usehooks-ts": "^2.9.1",
100+
"vite-plugin-dts": "^4.5.3"
98101
},
99102
"lint-staged": {
100103
"*.js": "eslint --cache --fix",

src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "../styles/global.css";
12
export { default as Accordion } from "./accordion";
23
export { default as CustomAccordion } from "./accordion/custom";
34

vite.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,34 @@ import react from "@vitejs/plugin-react";
44
import svgr from "vite-plugin-svgr";
55
// eslint-disable-next-line import/no-unresolved
66
import tailwindcss from "@tailwindcss/vite";
7+
import dts from "vite-plugin-dts";
78

89
export default defineConfig({
910
build: {
1011
lib: {
1112
entry: resolve(__dirname, "src/lib/index.ts"),
1213
name: "Kleros-UI-Components",
1314
},
15+
rollupOptions: {
16+
// make sure to externalize deps that shouldn't be bundled
17+
// into your library
18+
external: ["react", "react-dom"],
19+
output: {
20+
// Provide global variables to use in the UMD build
21+
// for externalized deps
22+
globals: {
23+
react: "React",
24+
"react-dom": "ReactDOM",
25+
},
26+
},
27+
},
1428
},
1529
plugins: [
1630
svgr({
1731
include: "**/*.svg",
1832
}),
1933
tailwindcss(),
2034
react(),
35+
dts({ insertTypesEntry: true }),
2136
],
2237
});

0 commit comments

Comments
 (0)