diff --git a/.changeset/cyan-cougars-trade.md b/.changeset/cyan-cougars-trade.md new file mode 100644 index 0000000000..d2ceb086ce --- /dev/null +++ b/.changeset/cyan-cougars-trade.md @@ -0,0 +1,5 @@ +--- +"@react-router/dev": patch +--- + +When `future.unstable_viteEnvironmentApi` is enabled and an absolute Vite `base` has been configured, ensure critical CSS is handled correctly during development diff --git a/contributors.yml b/contributors.yml index 6a2ad47915..168c978add 100644 --- a/contributors.yml +++ b/contributors.yml @@ -64,6 +64,7 @@ - chaance - chasinhues - chensokheng +- chr33s - chrisngobanh - christopherchudzicki - ChristophP diff --git a/packages/react-router-dev/vite/plugin.ts b/packages/react-router-dev/vite/plugin.ts index f1ea75deb5..76a3ff7983 100644 --- a/packages/react-router-dev/vite/plugin.ts +++ b/packages/react-router-dev/vite/plugin.ts @@ -1576,7 +1576,7 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => { if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi) { viteDevServer.middlewares.use(async (req, res, next) => { let [reqPathname, reqSearch] = (req.url ?? "").split("?"); - if (reqPathname === `${ctx.publicPath}@react-router/critical.css`) { + if (reqPathname.endsWith("/@react-router/critical.css")) { let pathname = new URLSearchParams(reqSearch).get("pathname"); if (!pathname) { return next("No pathname provided");