From 23b4e880b15ca4155182a1646341d2e4b461d2cf Mon Sep 17 00:00:00 2001 From: Maximo Mussini Date: Thu, 12 Aug 2021 11:18:54 -0300 Subject: [PATCH] fix: CSS dependencies are tracked incorrectly when base is set The change in https://github.com/vitejs/vite/pull/4267 caused all CSS dependencies of files that are not CSS (Tailwind CSS JIT deps) to be tracked with the `base` prefix in the module graph. URLs in the module graph are normalized and are never prefixed with base and as a result changes to those files were not causing the CSS module to be invalidated. See https://github.com/tailwindlabs/tailwindcss/issues/4978#issuecomment-897620776 --- packages/vite/src/node/plugins/css.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 1956918658008f..4081edf2c12055 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -208,7 +208,9 @@ export function cssPlugin(config: ResolvedConfig): Plugin { isCSSRequest(file) ? moduleGraph.createFileOnlyEntry(file) : await moduleGraph.ensureEntryFromUrl( - await fileToUrl(file, config, this) + ( + await fileToUrl(file, config, this) + ).replace(config.base, '/') ) ) }