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.

Can i eject react-dev-utils files?

See original GitHub issue

Can someone tell me if is there any way to override webpackHotDevClient.js file (which is in the react-dev-utils package) and the webpack.config.js (which is in the react-scripts package) ?

In the webpackHotDevClient i want to change :

// Connect to WebpackDevServer via a socket.
var connection = new WebSocket(
  url.format({
    protocol: 'ws',
    hostname: window.location.hostname,
    port: window.location.port,
    // Hardcoded in WebpackDevServer
    pathname: '/sockjs-node',
  })
);

to

// Connect to WebpackDevServer via a socket.
var connection = new WebSocket(
  url.format({
    protocol: 'wss',
    hostname: window.location.hostname,
    port: window.location.port,
    // Hardcoded in WebpackDevServer
    pathname: '/sockjs-node',
  })
);

And in webpack.config.js change the publicPath property to publicPath: “/Apps/MyApp/app/”. Because my app is in mydomain.com/Apps/MyApp/app/

So i can use hot dev server reloading through https.

edit : i have tryed eject command and i have the webpack.config.js in a config folder but not the webpackHotDevClient.js file. So is it possible to have an equivalent or a work around so i can edit the webpackHotDevClient.js settings as said above. Right now i’m directly editing the file in the node_modules folder.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
djhouseknechtcommented, Dec 17, 2019

@shiglet , as a temporary fix you can do this to manually eject it:

  1. Copy node_modules/react-dev-utils/webpackHotDevClient.js to your app’s root project (something like: config/webpackHotDevClient.js).

    1. It should be in the same directory as your webpack.config.js and wepackDevServer.config.js.
  2. Edit these lines in config/webpackHotDevClient.js:

// find these two lines
var launchEditorEndpoint = require('./launchEditorEndpoint');
var formatWebpackMessages = require('./formatWebpackMessages');

// and change to 
var launchEditorEndpoint = require('react-dev-utils/launchEditorEndpoint');
var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');

// find and make your desired change
var connection = new WebSocket(
  url.format({
    protocol: window.location.protocol === 'https:' ? 'wss' : 'ws', // <- change to this
    hostname: window.location.hostname,
    port: window.location.port,
    // Hardcoded in WebpackDevServer
    pathname: '/sockjs-node',
  })
);
  1. Edit this line in config/webpack.configs.js
  // find this 
  isEnvDevelopment &&
  require.resolve('react-dev-utils/webpackHotDevClient'),

  // change to this
  isEnvDevelopment &&
  require.resolve('./webpackHotDevClient'),

That should give you the control you need. Once that new version of react-dev-utils is published, you can undo those changes to sync back up.

0reactions
heyimalexcommented, Dec 27, 2019

@djhouseknecht RE:

Is there a way to have react-dev-utils version bumped with those changes? I am not familiar with build/versioning process.

That PR should land in 3.3.1 which we’re planning to release soon. The holidays have slowed things down a bit, sorry for any trouble!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can i eject react-dev-utils files? - Stack Overflow
edit : i have tryed eject command and i have the webpack.config.js in a config folder but not the webpackHotDevClient.js file. So is...
Read more >
react-dev-utils - npm
Start using react-dev-utils in your project by running `npm i react-dev-utils`. ... If you don't use Create React App, or if you ejected, ......
Read more >
Everything you need to know about react-scripts
Running the eject script will remove the single build dependency from your project. That means it will copy the configuration files and the ......
Read more >
react-dev-utils | Yarn - Package Manager
react-dev-utils ... This package includes some utilities used by Create React App. ... Inside any created project that has not been ejected, run:...
Read more >
How to use the react-dev-utils/crossSpawn.sync function in ...
cmd file // to be deleted while it is running. This trips Windows up after the eject completes. // We'll read the batch...
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