only run browserslist once

master
Brad Cornes 2020-05-03 20:32:00 +01:00
parent 243c9b4011
commit f809595659
2 changed files with 8 additions and 3 deletions

View File

@ -43,7 +43,7 @@ export default async function getClassNames(
let configPath
let postcss
let tailwindcss
let browserslist
let browserslistModule
let version
configPath = await globSingle(CONFIG_GLOB, {
@ -61,7 +61,7 @@ export default async function getClassNames(
try {
// this is not required
browserslist = importFrom(configDir, 'browserslist')
browserslistModule = importFrom(configDir, 'browserslist')
} catch (_) {}
const sepLocation = semver.gte(version, '0.99.0')
@ -100,6 +100,11 @@ export default async function getClassNames(
}
const resolvedConfig = resolveConfig({ cwd: configDir, config })
const browserslist = browserslistModule
? browserslistModule(undefined, {
path: configDir,
})
: []
return {
version,

View File

@ -4,7 +4,7 @@ export function runPlugin(plugin, params = {}) {
const { config, browserslist, ...rest } = params
const browserslistTarget =
browserslist && browserslist().includes('ie 11') ? 'ie11' : 'relaxed'
browserslist && browserslist.includes('ie 11') ? 'ie11' : 'relaxed'
try {
;(plugin.handler || plugin)({