File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed
packages/@tailwindcss-upgrade/src Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,11 @@ export function migrateConfig(
1111 {
1212 configFilePath,
1313 jsConfigMigration,
14- } : { configFilePath : string ; jsConfigMigration : JSConfigMigration | null } ,
14+ } : { configFilePath : string | null ; jsConfigMigration : JSConfigMigration | null } ,
1515) : Plugin {
1616 function migrate ( ) {
1717 if ( ! sheet . isTailwindRoot ) return
18+ if ( ! configFilePath ) return
1819
1920 let alreadyInjected = ALREADY_INJECTED . get ( sheet )
2021 if ( alreadyInjected && alreadyInjected . includes ( configFilePath ) ) {
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export interface MigrateOptions {
1818 newPrefix : string | null
1919 designSystem : DesignSystem
2020 userConfig : Config | null
21- configFilePath : string
21+ configFilePath : string | null
2222 jsConfigMigration : JSConfigMigration | null
2323}
2424
Original file line number Diff line number Diff line change @@ -156,23 +156,33 @@ async function run() {
156156 stylesheets . map ( async ( sheet ) => {
157157 try {
158158 let config = configBySheet . get ( sheet )
159- let jsConfigMigration = jsConfigMigrationBySheet . get ( sheet )
159+ let jsConfigMigration = jsConfigMigrationBySheet . get ( sheet ) ?? null
160160
161161 if ( ! config ) {
162162 for ( let parent of sheet . ancestors ( ) ) {
163163 if ( parent . isTailwindRoot ) {
164164 config ??= configBySheet . get ( parent ) !
165- jsConfigMigration ??= jsConfigMigrationBySheet . get ( parent )
165+ jsConfigMigration ??= jsConfigMigrationBySheet . get ( parent ) ?? null
166166 break
167167 }
168168 }
169169 }
170170
171- if ( ! config ) return
171+ let designSystem = config ?. designSystem ?? ( await sheet . designSystem ( ) )
172+ if ( ! designSystem ) {
173+ return
174+ }
175+
176+ let newPrefix = config ?. newPrefix ?? null
177+ let userConfig = config ?. userConfig ?? null
178+ let configFilePath = config ?. configFilePath ?? null
172179
173180 await migrateStylesheet ( sheet , {
174- ...config ,
175- jsConfigMigration : jsConfigMigration ?? null ,
181+ newPrefix,
182+ designSystem,
183+ userConfig,
184+ configFilePath,
185+ jsConfigMigration,
176186 } )
177187 } catch ( e : any ) {
178188 error ( `${ e ?. message ?? e } in ${ highlight ( relative ( sheet . file ! , base ) ) } ` , { prefix : '↳ ' } )
You can’t perform that action at this time.
0 commit comments