Skip to content

Commit

Permalink
fix: 修复 target 参数赋值
Browse files Browse the repository at this point in the history
  • Loading branch information
zyao89 committed Apr 7, 2022
1 parent fdef13e commit 6c48db6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"release": "micro-app release",
"release:alpha": "npm run release -- --preRelease=alpha",
"release:next": "npm run release -- --preRelease=next",
"release:minor": "npm run release minor",
"release:patch": "npm run release patch"
"release:minor": "npm run release -- minor",
"release:patch": "npm run release -- patch"
},
"files": [
"src"
Expand Down
2 changes: 1 addition & 1 deletion src/commands/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = function buildCommand(api, opts) {
}
}

const webpackConfig = api.resolveWebpackConfig();
const webpackConfig = api.resolveWebpackConfig(undefined, api.target);

const options = api.config || {};

Expand Down
6 changes: 4 additions & 2 deletions src/extends/enhance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ module.exports = function WebpackAdapter(api, opts) {
delete _originalWebpackConfig.plugins; // 不接受 plugins
webpackChainConfig.merge(_originalWebpackConfig);

const target = api.target; // target, 默认 web
const target = api.target; // target, 默认 app
if (!webpackChainConfig.get('target')) {
if (isServer) {
if (target === 'app' && isServer) { // 默认值
webpackChainConfig.target('node');
} else if ([ 'app', 'lib', 'web' ].includes(target)) { // 其它类型外部自己设置
webpackChainConfig.target('web');
} else {
webpackChainConfig.target(target);
}
}

Expand Down

0 comments on commit 6c48db6

Please sign in to comment.