Created
February 6, 2019 11:07
-
-
Save timonweb/597d501c38e641973388061875bc4cb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const pathClient = "./node_modules/react-dev-utils/webpackHotDevClient.js"; | |
fs.writeFileSync( | |
pathClient, | |
fs | |
.readFileSync(pathClient) | |
.toString() | |
.replace( | |
`var connection = new SockJS( | |
url.format({ | |
protocol: window.location.protocol, | |
hostname: window.location.hostname, | |
port: window.location.port, | |
// Hardcoded in WebpackDevServer | |
pathname: '/sockjs-node', | |
}) | |
);`, | |
` | |
var scriptUrl = document.currentScript | |
? url.parse(document.currentScript.src) | |
: window.location; | |
var connection = new SockJS( | |
url.format({ | |
protocol: scriptUrl.protocol, | |
hostname: scriptUrl.hostname, | |
port: scriptUrl.port, | |
// Hardcoded in WebpackDevServer | |
pathname: '/sockjs-node', | |
}) | |
);` | |
) | |
); | |
const pathConfig = "./node_modules/react-scripts/config/webpackDevServer.config.js"; | |
fs.writeFileSync( | |
pathConfig, | |
fs | |
.readFileSync(pathConfig) | |
.toString() | |
.replace( | |
`const publicPath = '/';`, | |
`const publicPath = process.env.PUBLIC_PATH || '/';` | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment