gaearon / react-hot-boilerplate

Minimal live-editing example for React
MIT License
3.91k stars 879 forks source link

How can i get static files? #105

Closed Infonautica closed 7 years ago

Infonautica commented 7 years ago

Description

Have a trouble with static files entry: [ 'webpack-hot-middleware/client', './src/app' ], output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/static/' }

React applications is works fine, but without css and other static files. I put them in "dist" folder, but still cant get them, so: <script src="/static/bundle.js"></script> // Works fine <link href="/static/css/main.min.css" rel="stylesheet"> // Cant get

Environment

React Hot Loader version: 1.3.1

  1. node -v: 4.4.7
  2. npm -v: 3.10.5
  3. Operating system: Windows
  4. Browser and version: Chrome
arixse commented 7 years ago

add 'build' scripts config in package.json ,then run 'npm run build'

scripts:{
"build":"webpack --progress --profile --colors"
}
JasoonS commented 7 years ago

I'm having the exact same issue.

@arixse I feel you didn't quite understand the question. We would like to serve static files with the server during the development process.

JasoonS commented 7 years ago

The solution is detailed here.

For you adding app.use('/static', express.static('dist')) somewhere to your server.js file should do the trick. :)

calesce commented 7 years ago

Yep, see above for Express. For WebpackDevServer, use the contentBase option