Is it possible for build/index.html to function in browser without the need of a server (double click from file location) ?
See original GitHub issueHi everyone,
I’m struggling to find the solution to this issue I’m having with create-react-app. After running npm build I want to be able to open the index.html from build folder, in browser with ‘doubleclick’ from file location, without the need of npm or any server. I also want my routes and functionality of the app to work in this scenario, basically to have my client see the app without having to use any server. I’ve been doing some research on the matter but couldn’t find much. I would like to know if it’s possible and if anyone has any links or even solutions to share in case I’m missing something. I’m rather new to react and your help will mean a lot. I’m using ubuntu 17. My route in App.js looks like so :
class App extends React.Component {
render(){
return(
<Router basename="/">
<Switch>
<Route exact path="/" component={LoginComponent}/>
<Route path="/app" component={AppLayout}/>
</Switch>
</Router>
);
}
}
then my index.js looks like so:
ReactDOM.render(<App />, document.getElementById('root'));
After running npm run build and open build/index.html in browser it shows nothing. After inspecting I can see the <div id="root">
being there but displaying only the comment <!-- react-empty: 1 -->
.
Any help would be greatly appreciated Many thanks in advance.
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (4 by maintainers)
Top GitHub Comments
@gaearon Why do you need to serve it? Why can’t you just open build/index.html to view in the browser?
With the serve -s build the site works correctly in prod But when I click the index.html, the browser shows the blank page. React script doesn’t work.