Skip to content

Instantly share code, notes, and snippets.

@fivethreeo
Last active October 24, 2019 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fivethreeo/48558e2bf0ec228af4b4763d4199df0c to your computer and use it in GitHub Desktop.
Save fivethreeo/48558e2bf0ec228af4b4763d4199df0c to your computer and use it in GitHub Desktop.
--- webpackHotDevClient.orig.js 2019-10-24 21:33:25.464549772 +0200
+++ webpackHotDevClient.js 2019-10-24 21:40:27.485125571 +0200
@@ -22,7 +22,7 @@
url.format({
protocol: window.location.protocol,
hostname: window.location.hostname,
- port: parseInt(process.env.PORT || window.location.port, 10) + 1,
+ port: process.env.RAZZLE_HOTCLIENT_NOPORT ? '' : parseInt(process.env.PORT || window.location.port, 10) + 1,
pathname: launchEditorEndpoint,
search:
'?fileName=' +
@@ -62,7 +62,7 @@
url.format({
protocol: window.location.protocol,
hostname: window.location.hostname,
- port: parseInt(process.env.PORT || window.location.port, 10) + 1,
+ port: process.env.RAZZLE_HOTCLIENT_NOPORT ? '' : parseInt(process.env.PORT || window.location.port, 10) + 1,
// Hardcoded in WebpackDevServer
pathname: '/sockjs-node',
})
'use strict';
module.exports = {
modify: (defaultConfig, { target, dev }, webpack) => {
const config = defaultConfig;
if (dev) {
if (target === 'web') {
config.devServer.quiet = false;
config.devServer.public = 'localhost:443';
}
config.module.rules = config.module.rules.reduce((rules, rule) => {
if (rule.test &&
rule.test.toString()===/\.(js|jsx|mjs)$/.toString() &&
!rule.enforce) {
const { use, ...rest } = rule;
rules.push({ ...rule, ...{
exclude: /razzle-dev-utils\/webpackHotDevClient\.js/
}});
// yarn add patch-loader
// Use env var RAZZLE_HOTCLIENT_NOPORT=true
rules.push({ ...rest, ...{
use: [ ...use, {
loader: require.resolve('patch-loader'),
options: { patch: '../../customDevClientPort.diff' },
}],
include: /razzle-dev-utils\/webpackHotDevClient\.js/,
}});
}
else {
rules.push(rule);
}
return rules;
}, []);
}
return config;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment