Skip to content

Add HMR support to React via react-refresh  #850

Open
@hailwood

Description

@hailwood

It was pretty simple to add so I'm adding this here both for documentation purposes, but also this is probably something really helpful to enable by default if you use Encore.enableReactPreset()...

npm install @pmmmwh/react-refresh-webpack-plugin react-refresh
if(Encore.isDevServer()) {
  const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
  Encore.addPlugin(new ReactRefreshWebpackPlugin());

  Encore.configureBabel(config => {
    config.plugins.push(require('react-refresh/babel'))
  });
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions