Skip to content

Commit 57138b0

Browse files
committed
fix: fixed entry key
1 parent 45c67f4 commit 57138b0

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

src/extends/submodule/configParser.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@ module.exports = function configParser(selfConfig = {}) {
1212
const entry = subModule.entry || {};
1313
// fix entry path
1414
if (typeof entry === 'object') {
15+
const newEntry = {};
1516
Object.keys(entry).forEach(key => {
1617
const _entrys = entry[key];
1718
if (Array.isArray(_entrys)) {
18-
entry[getNewKey(key)] = _entrys.map(item => {
19+
newEntry[getNewKey(key)] = _entrys.map(item => {
1920
if (!tryRequire.resolve(item)) {
2021
return path.resolve(selfConfig.root, item);
2122
}
2223
return item;
2324
});
2425
} else if (typeof _entrys === 'string') {
2526
if (!tryRequire.resolve(_entrys)) {
26-
entry[getNewKey(key)] = [ path.resolve(selfConfig.root, _entrys) ];
27+
newEntry[getNewKey(key)] = [ path.resolve(selfConfig.root, _entrys) ];
2728
}
2829
}
2930
});
31+
return newEntry;
3032
} else if (Array.isArray(entry)) {
3133
return {
3234
[getNewKey('index')]: entry.map(item => {
@@ -60,14 +62,20 @@ module.exports = function configParser(selfConfig = {}) {
6062
}
6163

6264
function getNewKey(key) {
63-
return `${prefix()}_${namespace()}-${key}`;
65+
return `${prefix()}${namespace()}-${key}`;
66+
}
67+
68+
function outputDir() {
69+
const _outputDir = subModule.outputDir || false;
70+
return _outputDir;
6471
}
6572

6673
return {
6774
entry,
6875
namespace,
6976
prefix,
7077
fileName,
78+
outputDir,
7179
};
7280
};
7381

src/extends/submodule/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module.exports = function subModuleWebpack(api, opts) {
3333
namespace: _configParser.namespace(),
3434
entry: _configParser.entry(),
3535
fileName: _configParser.fileName(),
36+
outputDir: _configParser.outputDir(),
3637
});
3738

3839
// change config.pages
@@ -52,7 +53,7 @@ module.exports = function subModuleWebpack(api, opts) {
5253
// 生成 manifest
5354
api.modifyWebpackChain(webpackChain => {
5455
const otherOptions = Object.keys(config.subModule).reduce((obj, key) => {
55-
if (![ 'prefix', 'namespace', 'entry' ].includes(key)) {
56+
if (![ 'prefix', 'namespace', 'entry', 'outputDir' ].includes(key)) {
5657
obj[key] = config.subModule[key];
5758
}
5859
return obj;
@@ -80,6 +81,14 @@ module.exports = function subModuleWebpack(api, opts) {
8081
}])
8182
.end();
8283

84+
// change outputDir
85+
if (config.subModule && config.subModule.outputDir) {
86+
webpackChain
87+
.output
88+
.path(api.resolve(outputDir))
89+
.end();
90+
}
91+
8392
return api.applyPluginHooks('modifySubModuleWebpackChain', webpackChain);
8493
});
8594

0 commit comments

Comments
 (0)