Skip to content

Commit e42513c

Browse files
committed
Store roots on a per-environment basis
I’m not 100% sure that this is necessary but it might be needed
1 parent 503acd1 commit e42513c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/@tailwindcss-vite/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export type PluginOptions = {
2929
export default function tailwindcss(opts: PluginOptions = {}): Plugin[] {
3030
let servers: ViteDevServer[] = []
3131
let config: ResolvedConfig | null = null
32-
let roots = new Map<string, Root>()
32+
let rootsByEnv = new DefaultMap<string, Map<string, Root>>((env: string) => new Map())
3333

3434
let isSSR = false
3535
let shouldOptimize = true
@@ -134,6 +134,7 @@ export default function tailwindcss(opts: PluginOptions = {}): Plugin[] {
134134
using I = new Instrumentation()
135135
DEBUG && I.start('[@tailwindcss/vite] Generate CSS (serve)')
136136

137+
let roots = rootsByEnv.get(this.environment?.name ?? 'default')
137138
let root = roots.get(id)
138139
if (!root) {
139140
root ??= createRoot(this.environment ?? null, id)
@@ -170,6 +171,7 @@ export default function tailwindcss(opts: PluginOptions = {}): Plugin[] {
170171
using I = new Instrumentation()
171172
DEBUG && I.start('[@tailwindcss/vite] Generate CSS (build)')
172173

174+
let roots = rootsByEnv.get(this.environment?.name ?? 'default')
173175
let root = roots.get(id)
174176
if (!root) {
175177
root ??= createRoot(this.environment ?? null, id)

0 commit comments

Comments
 (0)