1
1
import { Scanner } from '@tailwindcss/oxide'
2
2
import fs from 'node:fs/promises'
3
- import { dirname , resolve } from 'node:path'
3
+ import path from 'node:path'
4
4
import { fileURLToPath } from 'node:url'
5
5
import { type Config } from 'tailwindcss'
6
6
import defaultTheme from 'tailwindcss/defaultTheme'
@@ -21,7 +21,7 @@ import { findStaticPlugins, type StaticPluginOptions } from './utils/extract-sta
21
21
import { info } from './utils/renderer'
22
22
23
23
const __filename = fileURLToPath ( import . meta. url )
24
- const __dirname = dirname ( __filename )
24
+ const __dirname = path . dirname ( __filename )
25
25
26
26
export type JSConfigMigration =
27
27
// Could not convert the config file, need to inject it as-is in a @config directive
@@ -195,21 +195,21 @@ async function migrateContent(
195
195
return unresolvedConfig . future ?. relativeContentPathsByDefault ?? false
196
196
} ) ( )
197
197
198
- let contentFiles = Array . isArray ( unresolvedConfig . content )
199
- ? unresolvedConfig . content
200
- : ( unresolvedConfig . content ?. files ?? [ ] ) . map ( ( content ) => {
201
- if ( typeof content === 'string' && contentIsRelative ) {
202
- return resolve ( dirname ( configPath ) , content )
198
+ let sourceGlobs = Array . isArray ( unresolvedConfig . content )
199
+ ? unresolvedConfig . content . map ( ( pattern ) => ( { base , pattern } ) )
200
+ : ( unresolvedConfig . content ?. files ?? [ ] ) . map ( ( pattern ) => {
201
+ if ( typeof pattern === 'string' && contentIsRelative ) {
202
+ return { base : path . dirname ( configPath ) , pattern : pattern }
203
203
}
204
- return content
204
+ return { base , pattern }
205
205
} )
206
206
207
- for ( let content of contentFiles ) {
208
- if ( typeof content !== 'string' ) {
209
- throw new Error ( 'Unsupported content value: ' + content )
207
+ for ( let { base , pattern } of sourceGlobs ) {
208
+ if ( typeof pattern !== 'string' ) {
209
+ throw new Error ( 'Unsupported content value: ' + pattern )
210
210
}
211
211
212
- let sourceFiles = patternSourceFiles ( { base, pattern : content } )
212
+ let sourceFiles = patternSourceFiles ( { base, pattern } )
213
213
214
214
let autoContentContainsAllSourceFiles = true
215
215
for ( let sourceFile of sourceFiles ) {
@@ -220,7 +220,7 @@ async function migrateContent(
220
220
}
221
221
222
222
if ( ! autoContentContainsAllSourceFiles ) {
223
- sources . push ( { base, pattern : content } )
223
+ sources . push ( { base, pattern } )
224
224
}
225
225
}
226
226
return sources
0 commit comments