Skip to content

Commit

Permalink
docs: add a note on wds v3 and webpack 5 browserslist (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmmmwh authored Dec 24, 2020
1 parent d0d13f2 commit d7c8bf7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pnpm add -D @pmmmwh/react-refresh-webpack-plugin react-refresh
```

The plugin depends on a package from the React team - `react-refresh`,
so you will have to install and configure it separately as demonstrated in the [Usage](#usage) section, too.
so you will have to install and configure it separately as demonstrated in the [Usage](#usage) section.

### TypeScript

Expand Down
18 changes: 18 additions & 0 deletions docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,21 @@ module.exports = {
],
};
```

## Webpack 5 compatibility issues with `webpack-dev-server@3`

In `webpack-dev-server@3`,
there is a bug causing it to mis-judge the runtime environment when the Webpack 5 `browserslist` target is used.

It then fallbacks to thinking a non-browser target is being used,
in turn skipping injection of the HMR runtime,
and thus breaking downstream integrations like this plugin.

To overcome this,
you can conditionally apply the `browserslist` only in production modes in your Webpack configuration:

```js
module.exports = {
target: process.env.NODE_ENV !== 'production' ? 'web' : 'browserslist',
};
```

0 comments on commit d7c8bf7

Please sign in to comment.