Skip to content

Commit b515382

Browse files
feat(themes): Add shadcn.css export (#6415)
Co-authored-by: Bryce Kalow <[email protected]>
1 parent 24dd397 commit b515382

File tree

5 files changed

+115
-59
lines changed

5 files changed

+115
-59
lines changed

.changeset/puny-hounds-eat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/themes': patch
3+
---
4+
5+
Add `shadcn.css` export for importing within stylesheets to resolve Tailwind not picking up the elements class names used within the shadcn theme.

packages/themes/package.json

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,36 @@
2424
},
2525
"license": "MIT",
2626
"author": "Clerk",
27-
"main": "dist/themes/src/index.js",
28-
"source": "src/index.js",
29-
"typings": "dist/themes/src/index.d.ts",
27+
"exports": {
28+
".": {
29+
"types": "./dist/index.d.ts",
30+
"import": "./dist/index.js",
31+
"require": "./dist/index.cjs"
32+
},
33+
"./shadcn.css": "./dist/themes/shadcn.css"
34+
},
35+
"main": "dist/index.cjs",
36+
"module": "dist/index.js",
37+
"types": "dist/index.d.ts",
3038
"files": [
3139
"dist"
3240
],
3341
"scripts": {
34-
"build": "tsc -p tsconfig.build.json",
42+
"build": "tsup",
3543
"clean": "rimraf ./dist",
36-
"dev": "tsc -p tsconfig.build.json --watch",
44+
"dev": "tsup --watch",
3745
"format": "node ../../scripts/format-package.mjs",
3846
"format:check": "node ../../scripts/format-package.mjs --check",
3947
"lint": "eslint src",
40-
"lint:attw": "attw --pack . --profile node16"
48+
"lint:attw": "attw --pack . --exclude-entrypoints shadcn.css --profile node16"
4149
},
4250
"dependencies": {
4351
"@clerk/types": "workspace:^",
4452
"tslib": "catalog:repo"
4553
},
46-
"devDependencies": {},
54+
"devDependencies": {
55+
"tsup": "catalog:repo"
56+
},
4757
"engines": {
4858
"node": ">=18.17.0"
4959
},

packages/themes/src/themes/shadcn.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@source "./shadcn.js";

packages/themes/tsup.config.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { cp, mkdir, readdir } from 'fs/promises';
2+
import { extname, join } from 'path';
3+
import { defineConfig } from 'tsup';
4+
5+
export default defineConfig({
6+
entry: ['./src/**/*.{ts,tsx}'],
7+
format: ['cjs', 'esm'],
8+
bundle: false,
9+
clean: true,
10+
minify: false,
11+
sourcemap: false,
12+
dts: true,
13+
tsconfig: './tsconfig.build.json',
14+
target: 'es2020',
15+
onSuccess: async () => {
16+
// Ensure dist/themes directory exists
17+
await mkdir('./dist/themes', { recursive: true });
18+
19+
// Copy all CSS files from src/themes to dist/themes
20+
try {
21+
const files = await readdir('./src/themes');
22+
const cssFiles = files.filter(file => extname(file) === '.css');
23+
24+
for (const cssFile of cssFiles) {
25+
await cp(join('./src/themes', cssFile), join('./dist/themes', cssFile));
26+
console.log(`✓ Copied ${cssFile}`);
27+
}
28+
} catch (error) {
29+
// Handle specific errors gracefully, log unexpected ones
30+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
31+
// Directory doesn't exist or no CSS files found, that's ok
32+
console.log('ℹ No themes directory or CSS files found, skipping copy');
33+
} else {
34+
// Log unexpected errors to avoid hiding real issues
35+
console.warn('⚠ Warning: Failed to copy CSS files:', error);
36+
}
37+
}
38+
},
39+
});

0 commit comments

Comments
 (0)