jpsierens / webpack-react-redux

A boilerplate for playing around with react, redux and react-router with the help of webpack.
MIT License
599 stars 196 forks source link

Open dist/index.html in browser, I got a blank page. #35

Closed nxf closed 4 years ago

nxf commented 6 years ago

I cloned the project from master, When npm start, I can see the page. But when I execute the command, npm run build, It produce the dist/index.html and css/jss. But When I access the index.html from browser, I can not see anything. It's blank.

helb commented 6 years ago

That's because the build output is meant to be served by a webserver, not just opened from disk. If you open the browser console (F12), you'd see something like this:

kookaburra_20180305_105332

That means the browser is trying to find main-xxx.min.js and main-xxx.min.css in the website root, which, when you open the file that way, is… none.

There are some easy to use webservers with no configuration needed, for example :

$ npm install -g http-server
$ cd dist
$ hs -o    # -o opens the browser automatically
Starting up http-server, serving ./
Available on:
  http://127.0.0.1:8080
Hit CTRL-C to stop the server