diff --git a/.changeset/little-cups-deliver.md b/.changeset/little-cups-deliver.md new file mode 100644 index 0000000000..40da7e8ed1 --- /dev/null +++ b/.changeset/little-cups-deliver.md @@ -0,0 +1,5 @@ +--- +"@react-router/dev": patch +--- + +When executing `react-router.config.ts` and `routes.ts` with `vite-node`, ensure that PostCSS config files are ignored diff --git a/packages/react-router-dev/vite/vite-node.ts b/packages/react-router-dev/vite/vite-node.ts index ed2adb872c..35ce0ebb61 100644 --- a/packages/react-router-dev/vite/vite-node.ts +++ b/packages/react-router-dev/vite/vite-node.ts @@ -36,6 +36,15 @@ export async function createContext({ optimizeDeps: { noDiscovery: true, }, + css: { + // This empty PostCSS config object prevents the PostCSS config file from + // being loaded. We don't need it in a React Router config context, and + // there's also an issue in Vite 5 when using a .ts PostCSS config file in + // an ESM project: https://github.com/vitejs/vite/issues/15869. Consumers + // can work around this in their own Vite config file, but they can't + // configure this internal usage of vite-node. + postcss: {}, + }, configFile: false, envFile: false, plugins: [],