Skip to content

Commit 8751a66

Browse files
committed
fix: refactoring code
1 parent 0e3d968 commit 8751a66

4 files changed

Lines changed: 77 additions & 285 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@
4646
]
4747
},
4848
"peerDependencies": {
49-
"@micro-app/cli": ">=0.3.6"
49+
"@micro-app/cli": "^0.3.10"
5050
},
5151
"devDependencies": {
52-
"@micro-app/cli": "^0.3.6",
53-
"@micro-app/plugin-deploy": "^0.0.6",
52+
"@micro-app/cli": "^0.3.15",
53+
"@micro-app/plugin-deploy": "^0.0.7",
5454
"@types/jest": "^24.9.1",
5555
"eslint-config-2o3t": "^2.0.1",
5656
"husky": "^3.1.0",

src/v1/createKoaServer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
'use strict';
22

3-
module.exports = function createKoaServer(api, {
4-
port: configPort = 8888,
5-
host: configHost = 'localhost',
6-
} = {}) {
3+
module.exports = function createKoaServer(api, opts) {
74

85
const logger = api.logger;
96

@@ -15,6 +12,9 @@ module.exports = function createKoaServer(api, {
1512
// const isDev = api.mode === 'development';
1613
logger.info('[compatible]', 'Starting Koa2 server...');
1714

15+
const serverConfig = api.serverConfig || {};
16+
const { port: configPort = 8888, host: configHost = 'localhost' } = serverConfig;
17+
1818
return function({ args }) {
1919
const app = new Koa();
2020
app._name = 'KOA2'; // 设置名称, 给后面插件判断使用

src/v1/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ module.exports = function(api, opts) {
88
type: api.API_TYPE.MODIFY,
99
description: 'compatible: 合并之后提供 webpack-chain 进行再次修改事件',
1010
});
11+
// fixed
1112
if (api.modifyChainWebpackConfig) {
1213
api.modifyChainWebpackConfig((...args) => api.applyPluginHooks('modifyChainWebpcakConfig', ...args));
1314
}
1415

1516
if (opts.server === true) {
1617
const createKoaServer = require('./createKoaServer');
17-
createKoaServer(api);
18+
createKoaServer(api, opts);
1819
}
1920

20-
// modify micros: 增加 scope
21-
2221
// 用于兼容老版本的 hooks 和 entrys
2322
api.onInitWillDone(() => {
2423
const serverMerge = require('./lib/merge-server');

0 commit comments

Comments
 (0)