Skip to content

Commit

Permalink
feat: 完善 根据用户配置端口号 启动
Browse files Browse the repository at this point in the history
  • Loading branch information
imsunhao committed Jun 27, 2019
1 parent 89fe889 commit 48532ed
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion @types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ declare namespace build {
/**
* build 通用 webpack 配置
*/
interface options extends BuildService.serverInitOptions {
interface options extends BuildService.serverInitOptions, BuildService.parsedArgs.serverStart {
/**
* 当前程序运行版本
*/
Expand Down
3 changes: 3 additions & 0 deletions doc/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ export default function(inject: ConfigOptions.getOptionsInject): ConfigOptions.o
const client: any = getClient(config, inject)
const server: any = getServer(config, inject)

const { port } = config

return {
env: ['SERVER_ENV', 'ENV', 'NODE_ENV'],
port,
babelrc: {
presets: [
[
Expand Down
16 changes: 16 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,20 @@ async function setWebpack(
process.env.PUBLIC_PATH = path
return options
}

/**
* 通过 用户的设定 完善 argv参数
* @param options build 通用 webpack 配置
* @param argv BuildService 通用 启动参数
*/
function completeArgvByUserConfig(
argv: BuildService.parsedArgs,
options: ConfigOptions.options
) {
if (!argv.port) argv.port = options.port
if (!argv.fileDescriptor) argv.fileDescriptor = options.fileDescriptor
return argv
}
/**
* 设置 静态文件后缀
* @param options build 通用 webpack 配置
Expand Down Expand Up @@ -284,6 +298,8 @@ export async function initConfig(

buildServiceConfig = options

argv = completeArgvByUserConfig(argv, options)

return options
}
/**
Expand Down

0 comments on commit 48532ed

Please sign in to comment.