Skip to content

Instantly share code, notes, and snippets.

@jaredpalmer
Created August 26, 2017 21:06
Show Gist options
  • Save jaredpalmer/8cd6a535e0db0cc4dea6bba22c052aee to your computer and use it in GitHub Desktop.
Save jaredpalmer/8cd6a535e0db0cc4dea6bba22c052aee to your computer and use it in GitHub Desktop.
Change the port in CRA's WebpackHotDevClient.
const fs = require('fs');
// Monkey-patch react-dev-utils to get the error overlay with SSR
const pathToDevClient = 'node_modules/react-dev-utils/webpackHotDevClient.js';
// The react-scripts default
const reactScriptsPort = 3000;
// Read the dev client out of node_modules
const HotDevClient = fs.readFileSync(pathToDevClient, 'utf8');
// Switch out the socket port.
fs.writeFileSync(
pathToDevClient,
HotDevClient.replace('window.location.port', 3000)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment