Skip to content

Commit

Permalink
fix: Bug where port is reassigned after given to devServer (#1530)
Browse files Browse the repository at this point in the history
Co-authored-by: Leah <[email protected]>
  • Loading branch information
rschristian and ForsakenHarmony authored Mar 6, 2021
1 parent c9c48db commit bf668b1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-fans-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact-cli': patch
---

Fixes bug causing wrong port to be given to Webpack config
7 changes: 4 additions & 3 deletions packages/cli/lib/lib/webpack/run-webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ const transformConfig = require('./transform-config');
const { error, isDir, warn } = require('../../util');

async function devBuild(env) {
let userPort = parseInt(process.env.PORT || env.port, 10) || 8080;
env.port = await getPort({ port: userPort });

let config = await clientConfig(env);

await transformConfig(env, config);

let userPort =
parseInt(process.env.PORT || config.devServer.port, 10) || 8080;
let port = await getPort({ port: userPort });
let port = config.devServer.port;

let compiler = webpack(config);
return new Promise((res, rej) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/lib/webpack/webpack-client-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ function isDev(config) {
publicPath: '/',
contentBase: src,
https: config.https,
port: process.env.PORT || config.port || 8080,
port: config.port,
host: process.env.HOST || config.host || '0.0.0.0',
disableHostCheck: true,
historyApiFallback: true,
Expand Down

0 comments on commit bf668b1

Please sign in to comment.