Open zdunecki opened 1 week ago
I fixed that by removing mdx
plugin from vite.config.ts. Since it's reasonable it would be great to have better developer experience here IMO.
Additionally react-router/remix requires configFile
inside vite createServer
and this leds to create vite config which is not really needed (below stackblitz demo). Because of that fact I did mistake to pass mdx
plugin twice.
Here's a demo: https://stackblitz.com/edit/vitejs-vite-mhy6h5?file=vite.config.ts
I've updated your demo and it worked.
I've removed all of the options from server.ts
and then it takes them from vite.config.ts
by default.
vite.config
import { reactRouter } from '@react-router/dev/vite';
import { defineConfig } from 'vite';
import mdx from '@mdx-js/rollup';
export default defineConfig({
plugins: [mdx(), reactRouter()],
optimizeDeps: {
include: ['react/jsx-runtime'],
},
});
server.ts
import { createServer } from 'vite';
async function startServer() {
const server = await createServer({});
await server.listen(5173);
server.printUrls();
server.bindCLIShortcuts({ print: true });
}
startServer();
StackBlitz doesn't let me save some why, so no link for the demo.
What version of React Router are you using?
v7
Steps to Reproduce
Demo: https://stackblitz.com/edit/vitejs-vite-xmllxz?file=package.json
Expected Behavior
As a user, I expect the same behaviour for a custom vite server as a react-router one when using a mdx plugin.
Actual Behavior
When I run a react-router via a custom vite server with @mdx-js/rollup plugin I got error:
Demo: https://stackblitz.com/edit/vitejs-vite-xmllxz?file=package.json