For some reason, when I use npm run serve, I can access my page just fine and the routes work as they are supposed to. However, when I use npm run build, I encounter a white screen even if I correct my asset directories. What am I doing wrong?
// App.tsx
import { Routes, Route, BrowserRouter } from 'react-router-dom';
/**
* Application entry point.
*
* @return {JSX.Element}
*/
const App: () => JSX.Element = (): JSX.Element => {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<h1>Hello world!</h1>} />
<Route path="/add" element={<h1>Hello add!</h1>} />
</Routes>
</BrowserRouter>
);
};
export default App;
I created a breakaway branch to isolate the issue and leave out any unnecessary code: https://bitbucket.org/blackboardd/shoppy/src/breakaway-for-router/.
If anyone wants to try running it:
git clone -b breakaway-for-router git@bitbucket.org:blackboardd/shoppy.git
cd shoppy
npm install
// This works fine.
npm run serve
// This has a blank white screen when the index.html file is opened, even with the asset directories corrected for local viewing.
npm run build
System Information: Visual Studio Code on Remote WSL 2 Windows 11 Version 21H2