Skip to content

Commit e672375

Browse files
feat: setup tailwind, and build css (#5)
* feat: setup tailwind, and build css * feat: watch and build tailwind, rework dev script
1 parent b8d671a commit e672375

File tree

8 files changed

+37
-4
lines changed

8 files changed

+37
-4
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
# production
1212
/build
1313
/dist
14+
src/styles/tailwind.output.css
1415

1516
# Storybook
1617
storybook-static
1718
*storybook.log
1819

19-
# lock file
20+
# yarn
2021
yarn.lock
22+
.yarn
2123

2224
# misc
2325
.DS_Store

.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodeLinker: node-modules
2+
3+
yarnPath: .yarn/releases/yarn-4.3.1.cjs

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
"dist"
99
],
1010
"scripts": {
11-
"build": "tsup",
11+
"build:css": "tailwindcss -i src/styles/tailwind.css -o src/styles/tailwind.output.css --minify",
12+
"watch:css": "tailwindcss -i src/styles/tailwind.css -o src/styles/tailwind.output.css --watch",
13+
"dev": "concurrently \"yarn watch:css\" \"yarn storybook\"",
14+
"build": "yarn build:css && tsup",
1215
"clean": "rm -rf dist",
13-
"dev": "tsup --watch",
1416
"test": "jest",
1517
"prepublishOnly": "npm run build",
1618
"storybook": "storybook dev -p 6006",
@@ -37,12 +39,17 @@
3739
"@testing-library/react": "^16.0.0",
3840
"@types/react": "^18.3.3",
3941
"@types/react-dom": "^18.3.0",
42+
"autoprefixer": "^10.4.19",
43+
"concurrently": "^8.2.2",
4044
"jest": "^29.7.0",
4145
"jest-environment-jsdom": "^29.7.0",
46+
"postcss": "^8.4.38",
4247
"react": "^17.0.0 || ^18.0.0",
4348
"react-dom": "^17.0.0 || ^18.0.0",
4449
"storybook": "^8.1.10",
50+
"tailwindcss": "^3.4.4",
4551
"tsup": "^8.1.0",
4652
"typescript": "^5.5.2"
47-
}
53+
},
54+
"packageManager": "[email protected]"
4855
}

postcss.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
}

src/components/Button/Button.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// src/components/Button/Button.tsx
22

33
import React from 'react';
4+
import '../../styles/tailwind.output.css';
45

56
export interface ButtonProps {
67
label: string;

src/styles/tailwind.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

tailwind.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/** @type {import('tailwindcss').Config} */
2+
module.exports = {
3+
content: ['./src/**/*.{js,jsx,ts,tsx}'],
4+
theme: {
5+
extend: {},
6+
},
7+
plugins: [],
8+
}
9+

tsup.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import { defineConfig } from 'tsup';
33
export default defineConfig({
44
entry: ['src/index.ts'],
55
format: ['cjs', 'esm'],
6+
outDir: 'dist',
67
dts: true,
78
splitting: false,
89
sourcemap: true,
910
clean: true,
1011
external: ['react', 'react-dom'],
12+
injectStyle: true,
1113
});

0 commit comments

Comments
 (0)