From 2760f3097ef393b9f62c3ac4dd1d9fa150bf2e3a Mon Sep 17 00:00:00 2001
From: Andrey Viktorov
Date: Sun, 15 Feb 2026 16:44:00 +0700
Subject: [PATCH 1/3] Fallback to `config.createResolver` for `client` and ssr
environments
---
packages/@tailwindcss-vite/src/index.ts | 40 +++++++++++++++++++++++--
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/packages/@tailwindcss-vite/src/index.ts b/packages/@tailwindcss-vite/src/index.ts
index 4ad70ba43a34..78347a9d94f1 100644
--- a/packages/@tailwindcss-vite/src/index.ts
+++ b/packages/@tailwindcss-vite/src/index.ts
@@ -11,7 +11,13 @@ import { clearRequireCache } from '@tailwindcss/node/require-cache'
import { Scanner } from '@tailwindcss/oxide'
import fs from 'node:fs/promises'
import path from 'node:path'
-import type { Environment, Plugin, ResolvedConfig, ViteDevServer } from 'vite'
+import type {
+ Environment,
+ InternalResolveOptions,
+ Plugin,
+ ResolvedConfig,
+ ViteDevServer,
+} from 'vite'
import * as vite from 'vite'
const DEBUG = env.DEBUG
@@ -58,8 +64,36 @@ export default function tailwindcss(opts: PluginOptions = {}): Plugin[] {
customCssResolver = (id: string, base: string) => cssResolver(id, base, true, isSSR)
customJsResolver = (id: string, base: string) => jsResolver(id, base, true, isSSR)
} else {
+ type ResolveIdFn = (
+ environment: Environment,
+ id: string,
+ importer?: string,
+ aliasOnly?: boolean,
+ ) => Promise
+
+ // There are cases where Environment API is available,
+ // but `createResolver` is still overriden (for example astro v5)
+ //
+ // Copied as-is from vite, because this function is not a part of public API
+ //
+ // TODO: Remove this function and pre-environment code when Vite < 7 is no longer supported
+ function createBackCompatIdResolver(
+ config: ResolvedConfig,
+ options?: Partial,
+ ): ResolveIdFn {
+ const compatResolve = config.createResolver(options)
+ let resolve: ResolveIdFn
+ return async (environment, id, importer, aliasOnly) => {
+ if (environment.name === 'client' || environment.name === 'ssr') {
+ return compatResolve(id, importer, aliasOnly, environment.name === 'ssr')
+ }
+ resolve ??= vite.createIdResolver(config, options)
+ return resolve(environment, id, importer, aliasOnly)
+ }
+ }
+
// Newer Vite versions
- let cssResolver = vite.createIdResolver(env.config, {
+ let cssResolver = createBackCompatIdResolver(env.config, {
...env.config.resolve,
extensions: ['.css'],
mainFields: ['style'],
@@ -68,7 +102,7 @@ export default function tailwindcss(opts: PluginOptions = {}): Plugin[] {
preferRelative: true,
})
- let jsResolver = vite.createIdResolver(env.config, env.config.resolve)
+ let jsResolver = createBackCompatIdResolver(env.config, env.config.resolve)
customCssResolver = (id: string, base: string) => cssResolver(env, id, base, true)
customJsResolver = (id: string, base: string) => jsResolver(env, id, base, true)
From c3f5669833e97f133ab2923ca924dd511dd83cf7 Mon Sep 17 00:00:00 2001
From: Robin Malfait
Date: Tue, 17 Feb 2026 20:26:40 +0100
Subject: [PATCH 2/3] add integration test
---
integrations/vite/astro.test.ts | 72 ++++++++++++++++++++++++++++++++-
1 file changed, 71 insertions(+), 1 deletion(-)
diff --git a/integrations/vite/astro.test.ts b/integrations/vite/astro.test.ts
index 43406624c316..f828b5071b60 100644
--- a/integrations/vite/astro.test.ts
+++ b/integrations/vite/astro.test.ts
@@ -1,4 +1,4 @@
-import { candidate, fetchStyles, html, js, json, retryAssertion, test, ts } from '../utils'
+import { candidate, css, fetchStyles, html, js, json, retryAssertion, test, ts } from '../utils'
test(
'dev mode',
@@ -129,3 +129,73 @@ test(
await fs.expectFileToContain(files[0][0], [candidate`underline`, candidate`overline`])
},
)
+
+// https://github.com/tailwindlabs/tailwindcss/issues/19677
+test(
+ 'import aliases should work in
+
+
+ Astro
+
+