You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In development mode (after running npm start), all routes are performing as expected.
After running npm run build && npm run preview, in preview or production mode, the routing fails without any error or warning.
I'm sharing a few code snippets which should be useful to determine the root cause.
This code works fine in both dev and after build.
However, after I add children to any of the routes, will work fine only in dev mode, while after build an empty page is displayed.
Furthermore, after build, the parent element is not displayed.
And this is the vite.config.mts code:
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsconfigPaths from 'vite-tsconfig-paths';
export default defineConfig({
// depending on your application, base can also be "/"
base: '/',
plugins: [react(), viteTsconfigPaths()],
server: {
// this ensures that the browser opens upon server start
open: true,
// this sets a default port to 3000
port: 3000,
}
});
Any suggestions to what could cause this behavior?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In development mode (after running
npm start
), all routes are performing as expected.After running
npm run build && npm run preview
, in preview or production mode, the routing fails without any error or warning.I'm sharing a few code snippets which should be useful to determine the root cause.
To simplify, I tested this:
This code works fine in both dev and after build.
However, after I add children to any of the routes, will work fine only in dev mode, while after build an empty page is displayed.
Furthermore, after build, the parent element is not displayed.
And this is the
vite.config.mts
code:Any suggestions to what could cause this behavior?
Beta Was this translation helpful? Give feedback.
All reactions