File tree Expand file tree Collapse file tree 3 files changed +8
-11
lines changed
Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ function getPublicPath({
2525 const { dev, output, server } = config ;
2626
2727 let publicPath = DEFAULT_ASSET_PREFIX ;
28- const port = context . devServer ?. port || server . port || DEFAULT_PORT ;
2928
3029 if ( isProd ) {
3130 if ( typeof output . assetPrefix === 'string' ) {
@@ -53,6 +52,7 @@ function getPublicPath({
5352 }
5453 }
5554
55+ const port = ( isProd ? server . port : context . devServer ?. port ) ?? DEFAULT_PORT ;
5656 return formatPublicPath ( replacePortPlaceholder ( publicPath , port ) ) ;
5757}
5858
Original file line number Diff line number Diff line change 11import { isAbsolute , join } from 'node:path' ;
22import rspack from '@rspack/core' ;
33import { normalizePublicDirs } from '../config' ;
4- import { DEFAULT_PORT } from '../constants' ;
54import { isMultiCompiler } from '../helpers' ;
65import { logger } from '../logger' ;
76import type {
@@ -124,13 +123,12 @@ const applyDefaultMiddlewares = async ({
124123
125124 if (
126125 typeof dev . lazyCompilation === 'object' &&
127- typeof dev . lazyCompilation . serverUrl === 'string'
126+ typeof dev . lazyCompilation . serverUrl === 'string' &&
127+ context . devServer
128128 ) {
129- const port = context . devServer ?. port || server . port || DEFAULT_PORT ;
130-
131129 dev . lazyCompilation . serverUrl = replacePortPlaceholder (
132130 dev . lazyCompilation . serverUrl ,
133- port ,
131+ context . devServer . port ,
134132 ) ;
135133 }
136134
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import net from 'node:net';
44import type { Socket } from 'node:net' ;
55import os from 'node:os' ;
66import { posix , relative , sep } from 'node:path' ;
7- import { DEFAULT_DEV_HOST , DEFAULT_PORT } from '../constants' ;
7+ import { DEFAULT_DEV_HOST } from '../constants' ;
88import {
99 addTrailingSlash ,
1010 color ,
@@ -310,14 +310,13 @@ export const getServerConfig = async ({
310310 https : boolean ;
311311 portTip : string | undefined ;
312312} > => {
313- const host = config . server . host || DEFAULT_DEV_HOST ;
314- const originalPort = config . server . port || DEFAULT_PORT ;
313+ const { host, port : originalPort , strictPort } = config . server ;
315314 const port = await getPort ( {
316315 host,
317316 port : originalPort ,
318- strictPort : config . server . strictPort || false ,
317+ strictPort,
319318 } ) ;
320- const https = Boolean ( config . server . https ) || false ;
319+ const https = Boolean ( config . server . https ) ;
321320 const portTip =
322321 port !== originalPort
323322 ? `port ${ originalPort } is in use, ${ color . yellow ( `using port ${ port } .` ) } `
You can’t perform that action at this time.
0 commit comments