webpack-encore
webpack-encore copied to clipboard
Add HMR support to React via react-refresh
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'))
});
}
In my case, I had to disable liveReload from the dev-server options to work
@ahmed-saber yep, see #931
This works like a charm!