From 8266d6b0aa4ba58402cff320445d88adac8dc449 Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Tue, 25 Apr 2023 16:47:12 +0100 Subject: [PATCH] Resolve helper functions in CSS previews (#766) --- packages/tailwindcss-language-server/src/server.ts | 7 +++++++ packages/tailwindcss-language-service/src/util/jit.ts | 1 + packages/tailwindcss-language-service/src/util/state.ts | 1 + 3 files changed, 9 insertions(+) diff --git a/packages/tailwindcss-language-server/src/server.ts b/packages/tailwindcss-language-server/src/server.ts index 6f31a61..d981fdd 100644 --- a/packages/tailwindcss-language-server/src/server.ts +++ b/packages/tailwindcss-language-server/src/server.ts @@ -767,6 +767,13 @@ async function createProjectService( .default ), }, + evaluateTailwindFunctions: { + module: firstOptional( + () => + require(resolveFrom(configDir, 'tailwindcss/lib/lib/evaluateTailwindFunctions')) + .default + ), + }, } } catch (_) { try { diff --git a/packages/tailwindcss-language-service/src/util/jit.ts b/packages/tailwindcss-language-service/src/util/jit.ts index 40250d1..8ad7a30 100644 --- a/packages/tailwindcss-language-service/src/util/jit.ts +++ b/packages/tailwindcss-language-service/src/util/jit.ts @@ -18,6 +18,7 @@ export function generateRules( let root = state.modules.postcss.module.root({ nodes: rules.map(([, rule]) => rule) }) state.modules.jit.expandApplyAtRules.module(state.jitContext)(root) + state.modules.jit.evaluateTailwindFunctions?.module?.(state.jitContext)(root) let actualRules: Rule[] = [] root.walkRules((subRule) => { diff --git a/packages/tailwindcss-language-service/src/util/state.ts b/packages/tailwindcss-language-service/src/util/state.ts index 5b8153a..cc2c416 100644 --- a/packages/tailwindcss-language-service/src/util/state.ts +++ b/packages/tailwindcss-language-service/src/util/state.ts @@ -110,6 +110,7 @@ export interface State { generateRules: { module: any } createContext: { module: any } expandApplyAtRules: { module: any } + evaluateTailwindFunctions?: { module: any } } } browserslist?: string[]