Error: React Router Vite plugin can't detect preamble. Something is wrong. #12655
-
| Using  I've used this setup several times with the vite/react plugin, usually like this: However, with the reactRouter plugin I'm having the following issue, after adding  I'm getting the same error whether I use the config: or The error seems to originate from this plugin from the following line: Reproducer: https://github.com/akoskm/react-router-with-vitest Does anyone know how can I fix this? | 
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
| tl;dr: // ..
export default defineConfig({
  plugins: [!process.env.VITEST && reactRouter()],
  // ..
});@akoskm I found this thread when I ran into this exact same issue. Then I found this really good article about it: Then I came back here to share a link to that article here aaaaand after looking at your username, it seems like that's not necessary! Thanks for the help, looks like you figured it out :) | 
Beta Was this translation helpful? Give feedback.
-
| Face the same issue. Thanks both @akoskm & @ianjmacintosh In case if someone has the same issue as mine; running interaction test in Storybook UI and CLI, here is what I did, const isStorybook = process.argv[1]?.includes('storybook')
export default defineConfig({
  plugins: [!isStorybook && !process.env.VITEST && reactRouter()],
  // ..
}); | 
Beta Was this translation helpful? Give feedback.
tl;dr:
Update
vite.config.tswith:@akoskm I found this thread when I ran into this exact same issue.
Then I found this really good article about it:
https://akoskm.com/react-router-vitest-example/
Then I came back here to share a link to that article here aaaaand after looking at your username, it seems like that's not necessary!
Thanks for the help, looks like you figured it out :)