resolve workspace dependencies relative to config file

master
Brad Cornes 2020-04-29 19:20:37 +01:00
parent 387419d031
commit 2cd29c13d6
1 changed files with 7 additions and 5 deletions

View File

@ -10,6 +10,7 @@ import getPlugins from './getPlugins'
import getVariants from './getVariants' import getVariants from './getVariants'
import resolveConfig from './resolveConfig' import resolveConfig from './resolveConfig'
import * as util from 'util' import * as util from 'util'
import * as path from 'path'
import { glob } from './glob' import { glob } from './glob'
import { getUtilityConfigMap } from './getUtilityConfigMap' import { getUtilityConfigMap } from './getUtilityConfigMap'
@ -51,9 +52,10 @@ export default async function getClassNames(
}) })
invariant(configPath.length === 1, 'No Tailwind CSS config found.') invariant(configPath.length === 1, 'No Tailwind CSS config found.')
configPath = configPath[0] configPath = configPath[0]
postcss = importFrom(cwd, 'postcss') const configDir = path.dirname(configPath)
tailwindcss = importFrom(cwd, 'tailwindcss') postcss = importFrom(configDir, 'postcss')
version = importFrom(cwd, 'tailwindcss/package.json').version tailwindcss = importFrom(configDir, 'tailwindcss')
version = importFrom(configDir, 'tailwindcss/package.json').version
const sepLocation = semver.gte(version, '0.99.0') const sepLocation = semver.gte(version, '0.99.0')
? ['separator'] ? ['separator']
@ -90,7 +92,7 @@ export default async function getClassNames(
delete config[sepLocation] delete config[sepLocation]
} }
const resolvedConfig = resolveConfig({ cwd, config }) const resolvedConfig = resolveConfig({ cwd: configDir, config })
return { return {
version, version,
@ -102,7 +104,7 @@ export default async function getClassNames(
plugins: getPlugins(config), plugins: getPlugins(config),
variants: getVariants({ config, version, postcss }), variants: getVariants({ config, version, postcss }),
utilityConfigMap: await getUtilityConfigMap({ utilityConfigMap: await getUtilityConfigMap({
cwd, cwd: configDir,
resolvedConfig, resolvedConfig,
postcss, postcss,
}), }),