Skip to content

Commit 892fdc7

Browse files
committed
only link stylesheets to JS config files when migrating Tailwind CSS v3 projects
1 parent bc197f8 commit 892fdc7

File tree

1 file changed

+12
-8
lines changed
  • packages/@tailwindcss-upgrade/src

1 file changed

+12
-8
lines changed

packages/@tailwindcss-upgrade/src/index.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { isRepoDirty } from './utils/git'
2222
import { hoistStaticGlobParts } from './utils/hoist-static-glob-parts'
2323
import { pkg } from './utils/packages'
2424
import { eprintln, error, header, highlight, info, relative, success } from './utils/renderer'
25+
import * as version from './utils/version'
2526

2627
const options = {
2728
'--config': { type: 'string', description: 'Path to the configuration file', alias: '-c' },
@@ -98,14 +99,17 @@ async function run() {
9899
error(`${e?.message ?? e}`, { prefix: '↳ ' })
99100
}
100101

101-
// Ensure stylesheets are linked to configs
102-
try {
103-
await linkConfigsToStylesheets(stylesheets, {
104-
configPath: flags['--config'],
105-
base,
106-
})
107-
} catch (e: any) {
108-
error(`${e?.message ?? e}`, { prefix: '↳ ' })
102+
// Ensure stylesheets are linked to configs. But this is only necessary when
103+
// migrating from v3 to v4.
104+
if (version.isMajor(3)) {
105+
try {
106+
await linkConfigsToStylesheets(stylesheets, {
107+
configPath: flags['--config'],
108+
base,
109+
})
110+
} catch (e: any) {
111+
error(`${e?.message ?? e}`, { prefix: '↳ ' })
112+
}
109113
}
110114

111115
// Migrate js config files, linked to stylesheets

0 commit comments

Comments
 (0)