Skip to content

Commit 9f003fe

Browse files
committed
rejig config finder (tailwindlabs#130)
1 parent c5b5c1b commit 9f003fe

File tree

5 files changed

+85
-137
lines changed

5 files changed

+85
-137
lines changed

package-lock.json

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
"dlv": "^1.1.3",
171171
"dset": "^2.0.1",
172172
"esm": "^3.2.25",
173+
"fast-glob": "^3.2.4",
173174
"glob-exec": "^0.1.1",
174175
"globalyzer": "^0.1.4",
175176
"globrex": "^0.1.2",
@@ -179,6 +180,7 @@
179180
"mitt": "^1.2.0",
180181
"mkdirp": "^1.0.3",
181182
"moo": "^0.5.1",
183+
"normalize-path": "^3.0.0",
182184
"pkg-up": "^3.1.0",
183185
"postcss": "^7.0.27",
184186
"postcss-selector-parser": "^6.0.2",

src/class-names/glob.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/class-names/globSingle.js

Lines changed: 0 additions & 105 deletions
This file was deleted.

src/class-names/index.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import getVariants from './getVariants'
1212
import resolveConfig from './resolveConfig'
1313
import * as util from 'util'
1414
import * as path from 'path'
15-
import { globSingle } from './globSingle'
1615
import { getUtilityConfigMap } from './getUtilityConfigMap'
16+
import glob from 'fast-glob'
17+
import normalizePath from 'normalize-path'
1718

1819
function TailwindConfigError(error) {
1920
Error.call(this)
@@ -41,20 +42,25 @@ export default async function getClassNames(
4142
{ onChange = () => {} } = {}
4243
) {
4344
async function run() {
44-
let configPath
4545
let postcss
4646
let tailwindcss
4747
let browserslistModule
4848
let version
4949

50-
configPath = await globSingle(CONFIG_GLOB, {
51-
cwd,
52-
filesOnly: true,
53-
absolute: true,
54-
flush: true,
55-
})
56-
invariant(configPath.length === 1, 'No Tailwind CSS config found.')
57-
configPath = configPath[0]
50+
const configPaths = (
51+
await glob(CONFIG_GLOB, {
52+
cwd,
53+
ignore: ['**/node_modules'],
54+
onlyFiles: true,
55+
absolute: true,
56+
})
57+
)
58+
.map(normalizePath)
59+
.sort((a, b) => a.split('/').length - b.split('/').length)
60+
.map(path.normalize)
61+
62+
invariant(configPaths.length > 0, 'No Tailwind CSS config found.')
63+
const configPath = configPaths[0]
5864
const configDir = path.dirname(configPath)
5965
const tailwindBase = path.dirname(
6066
resolveFrom(configDir, 'tailwindcss/package.json')

0 commit comments

Comments
 (0)