From f809595659b9367834afc4b2a33cfa17ca670818 Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Sun, 3 May 2020 20:32:00 +0100 Subject: [PATCH] only run browserslist once --- src/class-names/index.js | 9 +++++++-- src/class-names/runPlugin.js | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/class-names/index.js b/src/class-names/index.js index 2aaec68..1e2d3e5 100644 --- a/src/class-names/index.js +++ b/src/class-names/index.js @@ -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, diff --git a/src/class-names/runPlugin.js b/src/class-names/runPlugin.js index c53f4ce..dbdd2b5 100644 --- a/src/class-names/runPlugin.js +++ b/src/class-names/runPlugin.js @@ -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)({