question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

react-app-rewire-hot-loader

See original GitHub issue

Hi, how to config when I use react-app-rewire-hot-loader? I tried, but didn’t work:

const path = require('path');
const rewireReactHotLoader = require('react-app-rewire-hot-loader');

const fixedHot = value => config => {
  config = rewireReactHotLoader(config, process.env);
  return config;
};

module.exports = {
  webpack: override(
    fixBabelImports('import', {
      libraryName: 'antd',
      libraryDirectory: 'es',
      style: 'css',
    }),
    addWebpackAlias({
      ['@@']: path.resolve(__dirname, 'src/')
    }),
    fixedHot(),
  ),
  devServer: function(configFunction) {
    return function(proxy, allowedHost) {
      const config = configFunction(proxy, allowedHost);
      config.hot = true;
      return config;
    }
  }
};

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9

github_iconTop GitHub Comments

11reactions
MeetzhDingcommented, May 25, 2019

@GloriaCHL @alexkreidler

I get this solution, and it’s work for me !

const { override, fixBabelImports } = require('customize-cra');
const rewireReactHotLoader = require('react-app-rewire-hot-loader');

module.exports = override(
  fixBabelImports('import', {
    libraryName: 'antd',
    libraryDirectory: 'es',
    style: 'css',
  }),
  (config, env) => {
    config = rewireReactHotLoader(config, env);
    return config;
  }
)

Other steps: http://npm.taobao.org/package/react-app-rewire-hot-loader

5reactions
quannh25595commented, Oct 2, 2019

I don’t know why but the env in @MeetzhDing seems to be undefined. And I found mode inside config. This code works for me:

const { override, fixBabelImports } = require('customize-cra');
const rewireReactHotLoader = require('react-app-rewire-hot-loader');

/* config-overrides.js */
module.exports = override(
  fixBabelImports('import', {
    libraryName: 'antd',
    libraryDirectory: 'es',
    style: 'css',
  }),
  config => {
    if (config.mode === 'development') {
      config.resolve.alias['react-dom'] = '@hot-loader/react-dom';
    }
    config = rewireReactHotLoader(config, config.mode);
    return config;
  },
);
Read more comments on GitHub >

github_iconTop Results From Across the Web

react-app-rewire-hot-loader
Start using react-app-rewire-hot-loader in your project by running `npm i react-app-rewire-hot-loader`. There are 8 other projects in the ...
Read more >
cdharris/react-app-rewire-hot-loader
Add the react-hot-loader to your create-react-app app via react-app-rewired . Because who wants their app, state, and styles automatically reloading all the ...
Read more >
Hot Reloading in Create React App Without Ejecting
The react-hot-loader Way. You can “rewire” Create React App without ejecting, which will allow you to enable real hot module reloading.
Read more >
react-app-rewire-hot-loader examples
Learn how to use react-app-rewire-hot-loader by viewing and forking example apps that make use of react-app-rewire-hot-loader on CodeSandbox.
Read more >
Stateful Hot Module Replacement with create-react-app v3
React -app-rewired allows you to implement small variations to CRA's default babel configuration, while still being able to merge back in future ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found