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

View File

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