Skip to content

Commit f809595

Browse files
author
Brad Cornes
committed
only run browserslist once
1 parent 243c9b4 commit f809595

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/class-names/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default async function getClassNames(
4343
let configPath
4444
let postcss
4545
let tailwindcss
46-
let browserslist
46+
let browserslistModule
4747
let version
4848

4949
configPath = await globSingle(CONFIG_GLOB, {
@@ -61,7 +61,7 @@ export default async function getClassNames(
6161

6262
try {
6363
// this is not required
64-
browserslist = importFrom(configDir, 'browserslist')
64+
browserslistModule = importFrom(configDir, 'browserslist')
6565
} catch (_) {}
6666

6767
const sepLocation = semver.gte(version, '0.99.0')
@@ -100,6 +100,11 @@ export default async function getClassNames(
100100
}
101101

102102
const resolvedConfig = resolveConfig({ cwd: configDir, config })
103+
const browserslist = browserslistModule
104+
? browserslistModule(undefined, {
105+
path: configDir,
106+
})
107+
: []
103108

104109
return {
105110
version,

src/class-names/runPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function runPlugin(plugin, params = {}) {
44
const { config, browserslist, ...rest } = params
55

66
const browserslistTarget =
7-
browserslist && browserslist().includes('ie 11') ? 'ie11' : 'relaxed'
7+
browserslist && browserslist.includes('ie 11') ? 'ie11' : 'relaxed'
88

99
try {
1010
;(plugin.handler || plugin)({

0 commit comments

Comments
 (0)