From 5834c0b000aeb6297a67fe185b69772de6e631c3 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Fri, 3 Feb 2023 10:56:16 -0500 Subject: [PATCH 1/3] fix: update tailwind config detection to also look for cjs Signed-off-by: Logan McAnsh --- packages/remix-dev/compiler/utils/postcss.ts | 14 ++++++++++---- packages/remix-dev/config.ts | 13 +++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/remix-dev/compiler/utils/postcss.ts b/packages/remix-dev/compiler/utils/postcss.ts index cbc3ae448b9..37ef10db3bc 100644 --- a/packages/remix-dev/compiler/utils/postcss.ts +++ b/packages/remix-dev/compiler/utils/postcss.ts @@ -4,6 +4,7 @@ import type { AcceptedPlugin, Processor } from "postcss"; import postcss from "postcss"; import type { RemixConfig } from "../../config"; +import { findConfig } from "../../config"; interface Options { config: RemixConfig; @@ -119,12 +120,17 @@ async function loadTailwindPlugin( try { // First ensure they have a Tailwind config - require.resolve("./tailwind.config", { paths: [rootDirectory] }); + // tailwind doesn't support esm config files yet + let tailwindConfigExtensions = [".js", ".cjs"]; + let tailwindConfig = findConfig( + rootDirectory, + "tailwind.config", + tailwindConfigExtensions + ); + if (!tailwindConfig) throw new Error("No Tailwind config found"); // Load Tailwind from the project directory - tailwindPath = require.resolve("tailwindcss", { - paths: [rootDirectory], - }); + tailwindPath = require.resolve("tailwindcss", { paths: [rootDirectory] }); } catch (err) { // If they don't have a Tailwind config or Tailwind installed, just ignore it. return null; diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index 118f3cb6d49..89b8fe377d8 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -359,7 +359,7 @@ export async function readConfig( } let rootDirectory = path.resolve(remixRoot); - let configFile = findConfig(rootDirectory, "remix.config"); + let configFile = findConfig(rootDirectory, "remix.config", configExts); let appConfig: AppConfig = {}; if (configFile) { @@ -581,9 +581,14 @@ function findEntry(dir: string, basename: string): string | undefined { const configExts = [".js", ".cjs", ".mjs"]; -function findConfig(dir: string, basename: string): string | undefined { - for (let ext of configExts) { - let file = path.resolve(dir, basename + ext); +export function findConfig( + dir: string, + basename: string, + extensions: string[] +): string | undefined { + for (let ext of extensions) { + let name = basename + ext; + let file = path.join(dir, name); if (fse.existsSync(file)) return file; } From caca662bf10ae62124044d1c9a21d6f922d75064 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 7 Feb 2023 11:52:39 -0500 Subject: [PATCH 2/3] Create fresh-toes-shout.md --- .changeset/fresh-toes-shout.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/fresh-toes-shout.md diff --git a/.changeset/fresh-toes-shout.md b/.changeset/fresh-toes-shout.md new file mode 100644 index 00000000000..c72d0bd7e3d --- /dev/null +++ b/.changeset/fresh-toes-shout.md @@ -0,0 +1,6 @@ +--- +"remix": patch +"@remix-run/dev": patch +--- + +allow tailwind.config.cjs when using `future.unstable_tailwind` From bcd2bd6bc75a460b70b33ae115b0ae630b2ee1a6 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 7 Feb 2023 13:33:09 -0500 Subject: [PATCH 3/3] Update packages/remix-dev/compiler/utils/postcss.ts --- packages/remix-dev/compiler/utils/postcss.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/remix-dev/compiler/utils/postcss.ts b/packages/remix-dev/compiler/utils/postcss.ts index 37ef10db3bc..1a6ae4023ac 100644 --- a/packages/remix-dev/compiler/utils/postcss.ts +++ b/packages/remix-dev/compiler/utils/postcss.ts @@ -131,7 +131,7 @@ async function loadTailwindPlugin( // Load Tailwind from the project directory tailwindPath = require.resolve("tailwindcss", { paths: [rootDirectory] }); - } catch (err) { + } catch { // If they don't have a Tailwind config or Tailwind installed, just ignore it. return null; }