Skip to content

Commit 1c8fe2b

Browse files
committed
Merge branch 'feature/webpack4' into develop
* feature/webpack4: :add: 增加 vusion-core 适配 adapter :update: adapter webpack4 # Conflicts: # package.json
2 parents fc5f6bc + 37b4290 commit 1c8fe2b

File tree

4 files changed

+919
-489
lines changed

4 files changed

+919
-489
lines changed

bin/micro-app-build.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
const program = require('commander');
55
const microApp = require('@micro-app/core');
6-
const chalk = require('chalk').default;
76

87
program
98
.version(require('../package').version, '-v, --version')
@@ -15,21 +14,22 @@ process.env.NODE_ENV = 'production';
1514
global.extraArgs = program.args;
1615

1716
const type = program.type;
18-
if (type === 'vusion') {
19-
const vusionAdapter = new microApp.VusionAdapter();
20-
vusionAdapter.build().then(() => {
21-
console.info('>>> Build Success >>>');
22-
}).catch(e => {
23-
console.error('>>> Build Error >>>', e);
24-
});
25-
} else if (!type || type === 'webpack') {
26-
// webpack build ...
27-
const webpackAdapter = new microApp.WebpackAdapter();
28-
webpackAdapter.build().then(() => {
29-
console.info('>>> Build Success >>>');
30-
}).catch(e => {
31-
console.error('>>> Build Error >>>', e);
32-
});
33-
} else {
34-
console.warn(chalk.red(`Not Support < ${type} >`));
17+
let wbpackAdapter = null;
18+
switch (type) {
19+
case 'vusion':
20+
wbpackAdapter = new microApp.VusionAdapter();
21+
break;
22+
case 'vusioncore':
23+
wbpackAdapter = new microApp.VusionCoreAdapter();
24+
break;
25+
case 'webpack':
26+
default:
27+
wbpackAdapter = new microApp.WebpackAdapter();
28+
break;
3529
}
30+
31+
wbpackAdapter.build().then(() => {
32+
console.info('>>> Build Success >>>');
33+
}).catch(e => {
34+
console.error('>>> Build Error >>>', e);
35+
});

bin/micro-app-dev.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,22 @@ process.env.NODE_ENV = 'development';
2121

2222
global.extraArgs = program.args;
2323

24-
const wbpackAdapter = program.type === 'vusion' ? new microApp.VusionAdapter() : new microApp.WebpackAdapter();
24+
const type = program.type;
25+
// const wbpackAdapter = program.type === 'vusion' ? new microApp.VusionAdapter() : new microApp.WebpackAdapter();
26+
let wbpackAdapter = null;
27+
switch (type) {
28+
case 'vusion':
29+
wbpackAdapter = new microApp.VusionAdapter();
30+
break;
31+
case 'vusioncore':
32+
wbpackAdapter = new microApp.VusionCoreAdapter();
33+
break;
34+
case 'webpack':
35+
default:
36+
wbpackAdapter = new microApp.WebpackAdapter();
37+
break;
38+
}
39+
2540
const koaAdapter = new microApp.KoaAdapter(wbpackAdapter, program);
2641
koaAdapter.serve(url => {
2742
// success

bin/micro-app-start.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,33 @@ process.env.NODE_ENV = 'production';
1818

1919
global.extraArgs = program.args;
2020

21+
22+
// const wbpackAdapter = program.type === 'vusion' ? new microApp.VusionAdapter() : new microApp.WebpackAdapter();
23+
let wbpackAdapter = null;
24+
switch (program.type) {
25+
case 'vusion':
26+
wbpackAdapter = new microApp.VusionAdapter();
27+
break;
28+
case 'vusioncore':
29+
wbpackAdapter = new microApp.VusionCoreAdapter();
30+
break;
31+
case 'webpack':
32+
default:
33+
wbpackAdapter = new microApp.WebpackAdapter();
34+
break;
35+
}
36+
2137
let promise = Promise.resolve();
2238
if (program.build) {
23-
const type = program.type;
24-
if (type === 'vusion') {
25-
const vusionAdapter = new microApp.VusionAdapter();
26-
promise = vusionAdapter.build().then(() => {
27-
return Promise.resolve(true);
28-
});
29-
} else {
30-
// webpack build ...
31-
const webpackAdapter = new microApp.WebpackAdapter();
32-
promise = webpackAdapter.build().then(() => {
33-
return Promise.resolve(true);
34-
});
35-
}
39+
promise = wbpackAdapter.build().then(() => {
40+
return Promise.resolve(true);
41+
});
3642
}
3743

3844
promise.then(flag => {
3945
if (flag) {
4046
logger.success('Build finish');
4147
}
42-
const wbpackAdapter = program.type === 'vusion' ? new microApp.VusionAdapter() : new microApp.WebpackAdapter();
4348
const koaAdapter = new microApp.KoaAdapter(wbpackAdapter, program);
4449
koaAdapter.start(url => {
4550
// success

0 commit comments

Comments
 (0)