webpacker-react icon indicating copy to clipboard operation
webpacker-react copied to clipboard

Config patch for HMR breaks with Webpacker 3.1

Open renchap opened this issue 7 years ago • 2 comments

Webpacker 3.1 introduces a new API to setup Webpacker, and this breaks our use of webpack-merge. This will be fixed in Webpacker 3.1.2, but we should switch to the Webpacker API to properly handle this.

See https://github.com/rails/webpacker/issues/1097

renchap avatar Dec 14 '17 22:12 renchap

Here's what you need, this working for me with webpacker 3.2, and maintaining state between patches.

development.js

const environment = require('./environment')
const merge = require('webpack-merge')

const babelLoader = environment.loaders.get('babel').use.find(el => el.loader === 'babel-loader')
babelLoader.options = merge(babelLoader.options, { plugins: ['react-hot-loader/babel'] })

const entries = environment.entry
Object.keys(entries).forEach((entry) => {
  entries.set(entry, ['react-hot-loader/patch', entries[entry]])
});

module.exports = environment.toWebpackConfig()

I'll create PR if you like?

raldred avatar Mar 18 '18 16:03 raldred

@renchap Is it on the roadmap to fix this? Currently this repo is incompatible with the latest stable release of rails (5.2). Is this repo still active?

ajsharp avatar Jan 14 '19 08:01 ajsharp