Skip to content

Commit 462308d

Browse files
Sort upgraded CSS (#14866)
During the migration process, a lot of changes to the CSS file happen. Some parts are converted, some parts are deleted and some new CSS is added. To make sure we are generating a sensible and good looking CSS file, we will sort the final CSS and pretty print it. The order we came up with looks like this: ```css /* Imports */ @import "tailwindcss"; @import "../other.css"; /* Configuration */ @config "../path/to/tailwindcss.config.js"; @plugin "my-plugin-1"; @plugin "my-plugin-2"; @source "./foo/**/*.ts"; @source "./bar/**/*.ts"; @variant foo {} @variant bar {} @theme {} /* Border compatibility CSS */ @layer base {} /* Utilities */ @Utility foo {} @Utility bar {} /* Rest of your own CSS if any */ ``` --------- Co-authored-by: Philipp Spiess <[email protected]>
1 parent 26638af commit 462308d

20 files changed

+467
-260
lines changed

integrations/upgrade/index.test.ts

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ test(
398398
If we ever want to remove these styles, we need to add an explicit border
399399
color utility to any element that depends on these defaults.
400400
*/
401-
402401
@layer base {
403402
*,
404403
::after,
@@ -1002,6 +1001,7 @@ test(
10021001
border-color: var(--color-gray-200, currentColor);
10031002
}
10041003
}
1004+
10051005
/*
10061006
Form elements have a 1px border by default in Tailwind CSS v4, so we've
10071007
added these compatibility styles to make sure everything still looks the
@@ -1193,6 +1193,7 @@ test(
11931193
11941194
--- ./src/a.1.utilities.1.css ---
11951195
@import './a.1.utilities.utilities.css';
1196+
11961197
@utility foo-from-a {
11971198
color: red;
11981199
}
@@ -1214,12 +1215,14 @@ test(
12141215
12151216
--- ./src/b.1.css ---
12161217
@import './b.1.components.css';
1218+
12171219
@utility bar-from-b {
12181220
color: red;
12191221
}
12201222
12211223
--- ./src/c.1.css ---
12221224
@import './c.2.css' layer(utilities);
1225+
12231226
.baz-from-c {
12241227
color: green;
12251228
}
@@ -1229,12 +1232,14 @@ test(
12291232
12301233
--- ./src/c.2.css ---
12311234
@import './c.3.css';
1235+
12321236
#baz {
12331237
--keep: me;
12341238
}
12351239
12361240
--- ./src/c.2.utilities.css ---
12371241
@import './c.3.utilities.css';
1242+
12381243
@utility baz-from-import {
12391244
color: yellow;
12401245
}
@@ -1417,6 +1422,8 @@ test(
14171422
/* Inject missing @config */
14181423
@import 'tailwindcss';
14191424
1425+
@config '../tailwind.config.ts';
1426+
14201427
/*
14211428
The default border color has changed to \`currentColor\` in Tailwind CSS v4,
14221429
so we've added these compatibility styles to make sure everything still
@@ -1434,6 +1441,7 @@ test(
14341441
border-color: var(--color-gray-200, currentColor);
14351442
}
14361443
}
1444+
14371445
/*
14381446
Form elements have a 1px border by default in Tailwind CSS v4, so we've
14391447
added these compatibility styles to make sure everything still looks the
@@ -1449,12 +1457,13 @@ test(
14491457
border-width: 0;
14501458
}
14511459
}
1452-
@config '../tailwind.config.ts';
14531460
14541461
--- ./src/root.2.css ---
14551462
/* Already contains @config */
14561463
@import 'tailwindcss';
14571464
1465+
@config "../tailwind.config.ts";
1466+
14581467
/*
14591468
The default border color has changed to \`currentColor\` in Tailwind CSS v4,
14601469
so we've added these compatibility styles to make sure everything still
@@ -1472,6 +1481,7 @@ test(
14721481
border-color: var(--color-gray-200, currentColor);
14731482
}
14741483
}
1484+
14751485
/*
14761486
Form elements have a 1px border by default in Tailwind CSS v4, so we've
14771487
added these compatibility styles to make sure everything still looks the
@@ -1487,12 +1497,23 @@ test(
14871497
border-width: 0;
14881498
}
14891499
}
1490-
@config "../tailwind.config.ts";
14911500
14921501
--- ./src/root.3.css ---
14931502
/* Inject missing @config above first @theme */
14941503
@import 'tailwindcss';
14951504
1505+
@config '../tailwind.config.ts';
1506+
1507+
@variant hocus (&:hover, &:focus);
1508+
1509+
@theme {
1510+
--color-red-500: #f00;
1511+
}
1512+
1513+
@theme {
1514+
--color-blue-500: #00f;
1515+
}
1516+
14961517
/*
14971518
The default border color has changed to \`currentColor\` in Tailwind CSS v4,
14981519
so we've added these compatibility styles to make sure everything still
@@ -1510,6 +1531,7 @@ test(
15101531
border-color: var(--color-gray-200, currentColor);
15111532
}
15121533
}
1534+
15131535
/*
15141536
Form elements have a 1px border by default in Tailwind CSS v4, so we've
15151537
added these compatibility styles to make sure everything still looks the
@@ -1525,22 +1547,12 @@ test(
15251547
border-width: 0;
15261548
}
15271549
}
1528-
@config '../tailwind.config.ts';
1529-
1530-
@variant hocus (&:hover, &:focus);
1531-
1532-
@theme {
1533-
--color-red-500: #f00;
1534-
}
1535-
1536-
@theme {
1537-
--color-blue-500: #00f;
1538-
}
15391550
15401551
--- ./src/root.4.css ---
15411552
/* Inject missing @config due to nested imports with tailwind imports */
15421553
@import './root.4/base.css';
15431554
@import './root.4/utilities.css';
1555+
15441556
@config '../tailwind.config.ts';
15451557
15461558
--- ./src/root.5.css ---
@@ -1591,6 +1603,8 @@ test(
15911603
/* Inject missing @config in this file, due to full import */
15921604
@import 'tailwindcss';
15931605
1606+
@config '../../tailwind.config.ts';
1607+
15941608
/*
15951609
The default border color has changed to \`currentColor\` in Tailwind CSS v4,
15961610
so we've added these compatibility styles to make sure everything still
@@ -1608,6 +1622,7 @@ test(
16081622
border-color: var(--color-gray-200, currentColor);
16091623
}
16101624
}
1625+
16111626
/*
16121627
Form elements have a 1px border by default in Tailwind CSS v4, so we've
16131628
added these compatibility styles to make sure everything still looks the
@@ -1623,7 +1638,6 @@ test(
16231638
border-width: 0;
16241639
}
16251640
}
1626-
@config '../../tailwind.config.ts';
16271641
"
16281642
`)
16291643
},
@@ -1681,6 +1695,7 @@ test(
16811695
border-color: var(--color-gray-200, currentColor);
16821696
}
16831697
}
1698+
16841699
/*
16851700
Form elements have a 1px border by default in Tailwind CSS v4, so we've
16861701
added these compatibility styles to make sure everything still looks the

0 commit comments

Comments
 (0)