gaearon / gaearon/react-hot-loader

devServer publicPath cause full refresh page

Open
#1,036 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12.2k
Forks
775
PR merge metrics
No merged PRs in 30d

Description

### Description

I was not able to apply RHL module to my app. After comparing with tons of examples I realized that it was something with devServer.

I cloned the example 'webpack modern' and remove **HtmlWebpackPlugin** so I could provide my html page. I had to add **devServer** to webpack config.

```js
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
mode: 'development',
entry: ['./src/index'],
output: {
path: path.join(__dirname, 'public', 'dist'),
filename: 'bundle.js',
},
module: {
rules: [
{
exclude: /node_modules|packages/,
test: /\.js$/,
use: 'babel-loader',
},
],
},
devServer: {
contentBase: path.join(__dirname ,'public'),
historyApiFallback: true
publicPath: '/dist/'
}
// Remove pluglins -> plugins: [new HtmlWebpackPlugin(), new webpack.NamedModulesPlugin()],
}
```
Then it statrs to fully refresh the page. So after trying multiple combitations I was able to get it by removing **publicPath** and changing my index.html
from
```js

```
to
```js

```

Does anyone have an explanation?

### Enviroment

React Hot Loader version: 4.3.3
node v8.1.3
npm v6.2.0
Operating system: Windows 10
Browser and version: Google Chrome Version 67.0.3396.99

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.