77 keyPathToCssProperty ,
88 themeableValues ,
99} from '../../tailwindcss/src/compat/apply-config-to-theme'
10+ import { darkModePlugin } from '../../tailwindcss/src/compat/dark-mode'
1011import { info } from './utils/renderer'
1112
1213const __filename = fileURLToPath ( import . meta. url )
@@ -27,6 +28,10 @@ export async function migrateJsConfig(fullConfigPath: string): Promise<void> {
2728
2829 let cssConfigs : string [ ] = [ ]
2930
31+ if ( 'darkMode' in unresolvedConfig ) {
32+ cssConfigs . push ( migrateDarkMode ( unresolvedConfig as any ) )
33+ }
34+
3035 if ( 'content' in unresolvedConfig ) {
3136 cssConfigs . push ( migrateContent ( unresolvedConfig as any ) )
3237 }
@@ -81,6 +86,18 @@ async function migrateTheme(unresolvedConfig: Config & { theme: any }): Promise<
8186 return css + '}\n'
8287}
8388
89+ function migrateDarkMode ( unresolvedConfig : Config & { darkMode : any } ) : string {
90+ let variant : string = ''
91+ let addVariant = ( _name : string , _variant : string ) => ( variant = _variant )
92+ let config = ( ) => unresolvedConfig . darkMode
93+ darkModePlugin ( { config, addVariant } )
94+
95+ if ( variant === '' ) {
96+ return ''
97+ }
98+ return `@variant dark (${ variant } );\n`
99+ }
100+
84101// Returns a string identifier used to section theme declarations
85102function createSectionKey ( key : string [ ] ) : string {
86103 let sectionSegments = [ ]
@@ -128,7 +145,7 @@ async function isSimpleConfig(unresolvedConfig: Config, source: string): Promise
128145 }
129146
130147 // The file may only contain known-migrateable high-level properties
131- const knownProperties = [ 'content' , 'theme' , 'plugins' , 'presets' ]
148+ const knownProperties = [ 'darkMode' , ' content', 'theme' , 'plugins' , 'presets' ]
132149 if ( Object . keys ( unresolvedConfig ) . some ( ( key ) => ! knownProperties . includes ( key ) ) ) {
133150 return false
134151 }
0 commit comments