Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ export async function migrate(designSystem: DesignSystem, userConfig: Config | n
let fullPath = path.isAbsolute(file) ? file : path.resolve(process.cwd(), file)
let contents = await fs.readFile(fullPath, 'utf-8')

await fs.writeFile(
fullPath,
await migrateContents(designSystem, userConfig, contents, extname(file)),
)
let migrated = await migrateContents(designSystem, userConfig, contents, extname(file))
if (migrated !== contents) {
await fs.writeFile(fullPath, migrated)
}
}
12 changes: 9 additions & 3 deletions packages/@tailwindcss-upgrade/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,23 +293,29 @@ async function run() {
let designSystem = await sheet.designSystem()
if (!designSystem) continue

let config = configBySheet.get(sheet)

// Figure out the source files to migrate
let sources = (() => {
// Disable auto source detection
if (compiler.root === 'none') {
return []
}

// No root specified, use the base directory
// No root specified — during a v3→v4 migration the CSS entrypoint won't
// have an @source directive yet. Use the content patterns from the v3 JS
// config if available, rather than falling back to '**/*' which would
// scan every file in the project (including migrations, vendor files, etc.).
if (compiler.root === null) {
if (config?.sources && config.sources.length > 0) {
return config.sources
}
return [{ base, pattern: '**/*', negated: false }]
}

// Use the specified root
return [{ ...compiler.root, negated: false }]
})().concat(compiler.sources)

let config = configBySheet.get(sheet)
let scanner = new Scanner({ sources })
let filesToMigrate = []
for (let file of scanner.files) {
Expand Down