Skip to content

Commit 7204408

Browse files
Migrating tailwindcss to v4 (#3058)
1 parent cefbdb1 commit 7204408

File tree

22 files changed

+146
-319
lines changed

22 files changed

+146
-319
lines changed

packages/cheatsheet-local/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
},
1616
"postcss": {
1717
"plugins": {
18-
"tailwindcss": {},
19-
"autoprefixer": {}
18+
"@tailwindcss/postcss": {}
2019
}
2120
},
2221
"scripts": {
@@ -35,21 +34,21 @@
3534
},
3635
"devDependencies": {
3736
"@effortlessmotion/html-webpack-inline-source-plugin": "^1.0.3",
37+
"@tailwindcss/postcss": "^4.1.11",
3838
"@testing-library/dom": "^10.4.0",
3939
"@testing-library/react": "^16.3.0",
4040
"@types/jest": "^30.0.0",
4141
"@types/node": "^24.1.0",
4242
"@types/react": "^19.1.8",
4343
"@types/react-dom": "^19.1.6",
4444
"@types/webpack": "^5.28.5",
45-
"autoprefixer": "^10.4.21",
4645
"css-loader": "^7.1.2",
4746
"html-webpack-plugin": "^5.6.3",
4847
"jest": "^30.0.5",
4948
"postcss": "^8.5.6",
5049
"postcss-loader": "^8.1.1",
5150
"style-loader": "^4.0.0",
52-
"tailwindcss": "^3.4.17",
51+
"tailwindcss": "^4.1.11",
5352
"ts-loader": "^9.5.2",
5453
"ts-node": "^10.9.2",
5554
"typescript": "^5.8.3",
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* You can add global styles to this file, and also import other style files */
2-
@tailwind components;
3-
@tailwind base;
4-
@tailwind utilities;
1+
@import "tailwindcss";
2+
3+
@config "../tailwind.config.js";

packages/cheatsheet-local/tailwind.config.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import { readFileSync } from "fs";
1+
import { readFileSync } from "node:fs";
22

33
const references = JSON.parse(
44
readFileSync("tsconfig.json", "utf-8"),
55
).references.map((ref) => ref.path);
66

7-
export const content = [".", ...references].map(
8-
(dir) => `${dir}/src/**/*!(*.stories|*.spec).{ts,tsx,html}`,
9-
);
10-
export const theme = {
11-
extend: {},
7+
/** @type {import('tailwindcss').Config} */
8+
export default {
9+
content: [".", ...references].flatMap((pkg) => [
10+
`${pkg}/src/**/*.{ts,tsx,html}`,
11+
`!${pkg}/src/**/*.{stories,spec}.{ts,tsx,html}`,
12+
]),
13+
theme: {
14+
extend: {},
15+
},
16+
plugins: [],
1217
};
13-
export const plugins = [];

packages/cheatsheet/src/lib/components/CheatsheetLegendComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default function CheatsheetLegendComponent({
3838
{data.map(({ term, definition, link, id }) => (
3939
<tr
4040
key={id}
41-
className="odd:bg-violet-200 dark:bg-violet-800 odd:dark:bg-violet-600"
41+
className="odd:bg-violet-200 dark:bg-violet-800 dark:odd:bg-violet-600"
4242
>
4343
<td className="px-1">{formatCaptures(`<${term}>`)}</td>
4444
<td className="border-l border-violet-400 px-1">

packages/cheatsheet/src/lib/components/SmartLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const SmartLink: React.FC<SmartLinkProps> = ({
2222
}) => {
2323
const className = noFormatting
2424
? ""
25-
: "text-blue-500 hover:text-violet-700 dark:text-cyan-400 hover:dark:text-violet-200";
25+
: "text-blue-500 hover:text-violet-700 dark:text-cyan-400 dark:hover:text-violet-200";
2626

2727
return (
2828
<span className={className}>

packages/cursorless-org-docs/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
},
1515
"postcss": {
1616
"plugins": {
17-
"tailwindcss": {},
18-
"autoprefixer": {}
17+
"@tailwindcss/postcss": {}
1918
}
2019
},
2120
"browserslist": {
@@ -71,7 +70,7 @@
7170
"@types/mdast": "^4.0.4",
7271
"@types/react": "^19.1.8",
7372
"postcss": "^8.5.6",
74-
"tailwindcss": "^3.4.17",
73+
"tailwindcss": "^4.1.11",
7574
"typescript": "^5.8.3",
7675
"unified": "^11.0.5"
7776
}

packages/cursorless-org-docs/src/css/custom.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
@tailwind components;
2-
@tailwind base;
3-
@tailwind utilities;
1+
@import "tailwindcss";
2+
3+
@config "../../tailwind.config.js";
44

55
/* From https://github.com/facebook/docusaurus/blob/cc0bceab9c1678303f6237f5526753edc1b12fc3/website/src/css/custom.css#L70-L86 */
66
.header-github-link:hover {

packages/cursorless-org-docs/src/plugins/tailwind-plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {
33
PluginOptions,
44
PostCssOptions,
55
} from "@docusaurus/types";
6-
import tailwindcss from "tailwindcss";
6+
import tailwindcss from "@tailwindcss/postcss";
77

88
export default function tailwindPlugin(
99
_context: LoadContext,
@@ -12,7 +12,7 @@ export default function tailwindPlugin(
1212
return {
1313
name: "tailwind-plugin",
1414

15-
configurePos1tCss(postcssOptions: PostCssOptions): PostCssOptions {
15+
configurePostCss(postcssOptions: PostCssOptions): PostCssOptions {
1616
postcssOptions.plugins.push(tailwindcss);
1717
return postcssOptions;
1818
},

packages/cursorless-org-docs/tailwind.config.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
/** @type {import('tailwindcss').Config} */
1+
import { readFileSync } from "node:fs";
22

3-
export const content = ["./src/**/*.{js,ts,jsx,tsx}"];
3+
const references = JSON.parse(
4+
readFileSync("tsconfig.json", "utf-8"),
5+
).references.map((ref) => ref.path);
46

5-
export const corePlugins = {
6-
preflight: false,
7+
/** @type {import('tailwindcss').Config} */
8+
export default {
9+
content: [".", ...references].map((pkg) => `${pkg}/src/**/*.{js,ts,jsx,tsx}`),
10+
theme: {
11+
extend: {},
12+
},
13+
corePlugins: {
14+
preflight: false,
15+
},
16+
plugins: [],
717
};
8-
9-
export const plugins = [];

packages/cursorless-org-docs/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"compilerOptions": {
44
"target": "es5",
55
"lib": ["dom", "es2022"],
6-
"moduleResolution": "node",
6+
"moduleResolution": "nodenext",
7+
"module": "nodenext",
78
"esModuleInterop": true,
89
"emitDeclarationOnly": false,
910
"jsx": "react"

0 commit comments

Comments
 (0)