From a15bee463fa44980ad248721a05eb54e490648e9 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Tue, 20 Sep 2022 10:18:50 -0400 Subject: [PATCH] wip --- src/cli.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/cli.js b/src/cli.js index 56eb85a8e..23121a239 100644 --- a/src/cli.js +++ b/src/cli.js @@ -20,6 +20,7 @@ import normalizePath from 'normalize-path' import micromatch from 'micromatch' import { validateConfig } from './util/validateConfig.js' import { parseCandidateFiles } from './lib/content.js' +import resolveConfigPath from './util/resolveConfigPath.js' let env = { DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== '0', @@ -441,9 +442,23 @@ async function build() { // So we want to use that one and only that one configPath = path.resolve(args['--config']) } else { + let postcssOptions = { + config: `./${configs.tailwind}`, + experimental: { + contextualPaths: args['--experimental-contextual-paths'], + }, + } + // The user has not specified an exact config file to use // So we want to find the closest one to the input file - configPath = `./${configs.tailwind}` + // when experimental contextual paths are enabled + let maybeConfigPath = resolveConfigPath(postcssOptions, path.resolve(input)) + + if (fs.existsSync(maybeConfigPath)) { + configPath = maybeConfigPath + } else { + configPath = null + } } async function loadPostCssPlugins() {