Skip to content

Commit 6da0859

Browse files
migrate to vite bundler and split tailwind classes
1 parent 8a2fae8 commit 6da0859

File tree

9 files changed

+67
-58
lines changed

9 files changed

+67
-58
lines changed

.storybook/preview.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { withThemeByClassName } from "@storybook/addon-themes"
22
import "../src/styles/tailwind.css"
3+
import "../src/styles/styles.css"
34

45
const preview = {
56
parameters: {

build.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

bun.lockb

-37.1 KB
Binary file not shown.

package.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,29 @@
1313
"type": "git",
1414
"url": "https://github.com/piotrkulpinski/design-system.git"
1515
},
16-
"main": "./src/index.ts",
17-
"types": "./src/index.ts",
16+
"files": ["dist"],
17+
"main": "./dist/index.umd.cjs",
18+
"module": "./dist/index.js",
19+
"exports": {
20+
".": {
21+
"types": "./dist/index.d.ts",
22+
"import": "./dist/index.js",
23+
"require": "./dist/index.umd.cjs"
24+
}
25+
},
1826
"scripts": {
1927
"dev": "storybook dev -p 6006 --no-open",
2028
"test": "bun test",
2129
"clean": "rimraf ./dist",
22-
"build": "bun run ./build.ts && tsc --emitDeclarationOnly",
30+
"build": "vite build && tsc --emitDeclarationOnly",
2331
"prebuild": "bun run clean",
2432
"release": "auto shipit --no-changelog",
2533
"build-storybook": "storybook build --test -o dist/storybook",
2634
"lint": "bun biome lint --apply .",
2735
"format": "bun biome format --write ."
2836
},
2937
"dependencies": {
30-
"@curiousleaf/utils": "^1.0.41",
38+
"@curiousleaf/utils": "^1.1.1",
3139
"@radix-ui/react-accordion": "^1.2.2",
3240
"@radix-ui/react-alert-dialog": "^1.1.4",
3341
"@radix-ui/react-avatar": "^1.1.2",
@@ -66,7 +74,7 @@
6674
"@storybook/theming": "^8.5.0",
6775
"@tailwindcss/container-queries": "^0.1.1",
6876
"@tailwindcss/typography": "^0.5.16",
69-
"@types/bun": "^1.1.16",
77+
"@types/bun": "^1.1.17",
7078
"@types/react": "^19.0.7",
7179
"@types/react-dom": "^19.0.3",
7280
"@vitejs/plugin-react": "^4.3.4",

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import "./styles/styles.css"
2+
13
export * from "./shared/classes"
24
export * from "./shared/cva"
35
export * from "./shared/helpers"

src/styles/styles.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@tailwind components;
2+
@tailwind utilities;
3+
4+
a,
5+
button,
6+
label[for],
7+
[class*="group-hover"] {
8+
@apply transition;
9+
@apply ease-out;
10+
@apply duration-150;
11+
@apply cursor-pointer;
12+
}
13+
14+
svg[stroke="currentColor"]:not([class*="stroke"]) {
15+
@apply stroke-[1.5];
16+
}
17+
18+
svg[stroke="currentColor"]:not([class*="size"]) {
19+
@apply size-icon;
20+
}
21+
22+
.dark {
23+
@apply bg-gray-900;
24+
@apply text-white;
25+
}
26+
27+
@supports (mask-image: paint(smooth-corners)) {
28+
.squircle {
29+
mask-image: paint(smooth-corners);
30+
--smooth-corners: 3;
31+
}
32+
}

src/styles/tailwind.css

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1 @@
11
@tailwind base;
2-
@tailwind components;
3-
@tailwind utilities;
4-
5-
a,
6-
button,
7-
label[for],
8-
[class*="group-hover"] {
9-
@apply transition;
10-
@apply ease-out;
11-
@apply duration-150;
12-
@apply cursor-pointer;
13-
}
14-
15-
svg[stroke="currentColor"]:not([class*="stroke"]) {
16-
@apply stroke-[1.5];
17-
}
18-
19-
svg[stroke="currentColor"]:not([class*="size"]) {
20-
@apply size-icon;
21-
}
22-
23-
.dark {
24-
@apply bg-gray-900;
25-
@apply text-white;
26-
}
27-
28-
@supports (mask-image: paint(smooth-corners)) {
29-
.squircle {
30-
mask-image: paint(smooth-corners);
31-
--smooth-corners: 3;
32-
}
33-
}

tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"strictNullChecks": true,
2020
"strict": true,
2121
"jsx": "react-jsx",
22+
"baseUrl": ".",
23+
"outDir": "./dist",
2224
"paths": { "~/*": ["./src/*"] }
2325
}
2426
}

vite.config.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1+
import { resolve } from "node:path"
12
import react from "@vitejs/plugin-react"
23
import { defineConfig } from "vite"
34
import tsconfigPaths from "vite-tsconfig-paths"
45

56
// https://vitejs.dev/config/
67
export default defineConfig({
78
plugins: [tsconfigPaths(), react()],
8-
resolve: {
9-
extensions: [".mdx", ".mjs", ".ts", ".tsx", ".js", ".jsx"],
9+
build: {
10+
lib: {
11+
entry: resolve(__dirname, "./src/index.ts"),
12+
name: "@curiousleaf/design",
13+
fileName: "index",
14+
},
15+
rollupOptions: {
16+
external: ["react", "react-dom", "react/jsx-runtime"],
17+
output: {
18+
globals: {
19+
react: "React",
20+
"react-dom": "ReactDOM",
21+
"react/jsx-runtime": "react/jsx-runtime",
22+
},
23+
},
24+
},
1025
},
1126
})

0 commit comments

Comments
 (0)