|
| 1 | +import path from 'node:path' |
1 | 2 | import { describe, expect } from 'vitest' |
2 | 3 | import { css, html, json, test, ts } from '../utils' |
3 | 4 |
|
@@ -938,6 +939,98 @@ test( |
938 | 939 | }, |
939 | 940 | ) |
940 | 941 |
|
| 942 | +test( |
| 943 | + 'migrate sources when pointing to folders outside the project root', |
| 944 | + { |
| 945 | + fs: { |
| 946 | + 'package.json': json` |
| 947 | + { |
| 948 | + "dependencies": { |
| 949 | + "@tailwindcss/upgrade": "workspace:^" |
| 950 | + } |
| 951 | + } |
| 952 | + `, |
| 953 | + |
| 954 | + 'frontend/tailwind.config.ts': ts` |
| 955 | + export default { |
| 956 | + content: { |
| 957 | + relative: true, |
| 958 | + files: ['./src/**/*.html', '../backend/mails/**/*.blade.php'], |
| 959 | + }, |
| 960 | + theme: { |
| 961 | + extend: { |
| 962 | + colors: { |
| 963 | + primary: 'red', |
| 964 | + }, |
| 965 | + }, |
| 966 | + }, |
| 967 | + } |
| 968 | + `, |
| 969 | + 'frontend/src/input.css': css` |
| 970 | + @tailwind base; |
| 971 | + @tailwind components; |
| 972 | + @tailwind utilities; |
| 973 | + @config "../tailwind.config.ts"; |
| 974 | + `, |
| 975 | + 'frontend/src/index.html': html`<div class="!text-primary"></div>`, |
| 976 | + |
| 977 | + 'backend/mails/welcome.blade.php': html`<div class="!text-primary"></div>`, |
| 978 | + }, |
| 979 | + }, |
| 980 | + async ({ root, exec, fs }) => { |
| 981 | + await exec('npx @tailwindcss/upgrade', { |
| 982 | + cwd: path.join(root, 'frontend'), |
| 983 | + }) |
| 984 | + |
| 985 | + expect(await fs.dumpFiles('frontend/**/*.css')).toMatchInlineSnapshot(` |
| 986 | + " |
| 987 | + --- frontend/src/input.css --- |
| 988 | + @import 'tailwindcss'; |
| 989 | +
|
| 990 | + @source '../../backend/mails/**/*.blade.php'; |
| 991 | +
|
| 992 | + @theme { |
| 993 | + --color-primary: red; |
| 994 | + } |
| 995 | +
|
| 996 | + /* |
| 997 | + The default border color has changed to \`currentColor\` in Tailwind CSS v4, |
| 998 | + so we've added these compatibility styles to make sure everything still |
| 999 | + looks the same as it did with Tailwind CSS v3. |
| 1000 | +
|
| 1001 | + If we ever want to remove these styles, we need to add an explicit border |
| 1002 | + color utility to any element that depends on these defaults. |
| 1003 | + */ |
| 1004 | + @layer base { |
| 1005 | + *, |
| 1006 | + ::after, |
| 1007 | + ::before, |
| 1008 | + ::backdrop, |
| 1009 | + ::file-selector-button { |
| 1010 | + border-color: var(--color-gray-200, currentColor); |
| 1011 | + } |
| 1012 | + } |
| 1013 | +
|
| 1014 | + /* |
| 1015 | + Form elements have a 1px border by default in Tailwind CSS v4, so we've |
| 1016 | + added these compatibility styles to make sure everything still looks the |
| 1017 | + same as it did with Tailwind CSS v3. |
| 1018 | +
|
| 1019 | + If we ever want to remove these styles, we need to add \`border-0\` to |
| 1020 | + any form elements that shouldn't have a border. |
| 1021 | + */ |
| 1022 | + @layer base { |
| 1023 | + input:where(:not([type='button'], [type='reset'], [type='submit'])), |
| 1024 | + select, |
| 1025 | + textarea { |
| 1026 | + border-width: 0; |
| 1027 | + } |
| 1028 | + } |
| 1029 | + " |
| 1030 | + `) |
| 1031 | + }, |
| 1032 | +) |
| 1033 | + |
941 | 1034 | describe('border compatibility', () => { |
942 | 1035 | test( |
943 | 1036 | 'migrate border compatibility', |
|
0 commit comments