Skip to content

Commit

Permalink
docs: update README to reflect the latest API changes [skip ci] (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmmmwh committed Feb 6, 2022
1 parent e307d50 commit 64eba28
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ module.exports = {

> **:memo: Note**:
>
> Even though both the Babel transform (`react-refresh/babel`) and this plugin have optimisations to do nothing in `production`,
> it is suggested to only have them both enabled in `development` mode to prevent shipping any additional code accidentally.
> Ensure you have only enabled both the Babel transform (`react-refresh/babel`) and this plugin in `development` mode!
<details>
<summary>Using <code>ts-loader</code></summary>
Expand All @@ -220,11 +219,13 @@ Then, instead of wiring up `react-refresh/babel` via `babel-loader`,
you can wire-up `react-refresh-typescript` with `ts-loader`:

```js
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const ReactRefreshTypeScript = require('react-refresh-typescript');

const isDevelopment = process.env.NODE_ENV !== 'production';

module.exports = {
mode: isDevelopment ? 'development' : 'production',
module: {
rules: [
{
Expand All @@ -244,6 +245,7 @@ module.exports = {
},
],
},
plugins: [isDevelopment && new ReactRefreshWebpackPlugin()].filter(Boolean),
};
```

Expand All @@ -266,7 +268,12 @@ Then, instead of wiring up `react-refresh/babel` via `babel-loader`,
you can wire-up `swc-loader` and use the `refresh` transform:

```js
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');

const isDevelopment = process.env.NODE_ENV !== 'production';

module.exports = {
mode: isDevelopment ? 'development' : 'production',
module: {
rules: [
{
Expand All @@ -290,6 +297,7 @@ module.exports = {
},
],
},
plugins: [isDevelopment && new ReactRefreshWebpackPlugin()].filter(Boolean),
};
```

Expand Down

0 comments on commit 64eba28

Please sign in to comment.