Skip to content

Commit 031672b

Browse files
committed
fix: dll resolveLoader.module config for easywebpack in framework
1 parent 7ff4a01 commit 031672b

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ coverage.lcov
1515
/package-lock.json
1616
dist
1717
app
18+
.vscode

lib/base.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,8 @@ class WebpackBaseBuilder extends Config {
315315

316316
installLoader(loaders) {
317317
const dependencies = this.dependencies;
318-
const modules = this.webpackConfig.resolveLoader && this.webpackConfig.resolveLoader.modules;
319318
const webpackLoaders = this.createLoader(loaders);
320-
this.utils.installLoader(webpackLoaders, dependencies, modules, this.config.install);
319+
this.utils.installLoader(webpackLoaders, dependencies, this.modules, this.config.install);
321320
return webpackLoaders;
322321
}
323322

@@ -335,7 +334,6 @@ class WebpackBaseBuilder extends Config {
335334

336335
createPlugin(plugins) {
337336
const webpackPlugins = [];
338-
const modules = this.webpackConfig.resolveLoader && this.webpackConfig.resolveLoader.modules;
339337
Object.keys(plugins).forEach(name => {
340338
const configInfo = plugins[name];
341339
if (this.isUse(configInfo)) {
@@ -351,7 +349,7 @@ class WebpackBaseBuilder extends Config {
351349
let Clazz = configInfo.name;
352350
if (this.utils.isString(configInfo.name)) {
353351
pluginName = configInfo.name;
354-
Clazz = this.utils.requireModule(configInfo.name, modules);
352+
Clazz = this.utils.requireModule(configInfo.name, this.modules);
355353
} else if (this.utils.isFunction(configInfo.name)) {
356354
pluginName = configInfo.name.name;
357355
}
@@ -377,7 +375,6 @@ class WebpackBaseBuilder extends Config {
377375
}
378376

379377
installPlugin(plugins) {
380-
const modules = this.webpackConfig.resolveLoader && this.webpackConfig.resolveLoader.modules;
381378
const dependencies = this.dependencies;
382379
const enablePlugins = {};
383380
Object.keys(plugins).forEach(name => {
@@ -386,7 +383,7 @@ class WebpackBaseBuilder extends Config {
386383
enablePlugins[name] = pluginInfo;
387384
}
388385
});
389-
return this.utils.installPlugin(enablePlugins, dependencies, modules, this.config.install);
386+
return this.utils.installPlugin(enablePlugins, dependencies, this.modules, this.config.install);
390387
}
391388

392389
adapterPlugin(plugins) {
@@ -449,16 +446,14 @@ class WebpackBaseBuilder extends Config {
449446

450447
combineWebpackConfig(config) {
451448
this.t3 = Date.now();
452-
const outerWebpackConfig = this.analysisWebpackConfig(config);
453-
const configWebpackConfig = this.mergeWebpackConfig(this.webpackConfig, outerWebpackConfig);
454449
const buildWebpackConfig = {
455450
output: this.createOutput(config),
456451
module: {
457452
rules: this.createWebpackLoader(config)
458453
},
459454
plugins: this.createWebpackPlugin(config)
460455
};
461-
const webpackConfig = this.mergeWebpackConfig(configWebpackConfig, buildWebpackConfig);
456+
const webpackConfig = this.mergeWebpackConfig(this.nativeWebpackConfig, buildWebpackConfig);
462457
this.t4 = Date.now();
463458
this.logger.cost();
464459
return webpackConfig;

lib/builder.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ exports.getDllWebpackConfig = (config, option = {}) => {
3636
const publicPath = config.publicPath;
3737
const buildPath = config.buildPath;
3838
const install = config.install;
39+
const resolveLoader = config.resolveLoader;
3940
const cdn = config.cdn;
4041
const configPlugins = config.plugins || {};
4142
const plugins = {};
@@ -49,7 +50,7 @@ exports.getDllWebpackConfig = (config, option = {}) => {
4950
}
5051
}
5152
dllArray.forEach(item => {
52-
const builderConfig = Object.assign({}, dllConfig, { entry: {}, dll: item, publicPath, buildPath, alias, externals, install, cdn, plugins }, item.webpackConfig);
53+
const builderConfig = Object.assign({}, dllConfig, { entry: {}, dll: item, publicPath, buildPath, alias, externals, resolveLoader, install, cdn, plugins }, item.webpackConfig);
5354
if (option.onlyView || utils.checkDllUpdate(config, item)) {
5455
dllWebpackConfig.push(new WebpackDllBuilder(builderConfig).create());
5556
}

lib/config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ class Config {
8282
return this.dev && this.utils.isTrue(config.proxy);
8383
}
8484

85+
get nativeWebpackConfig() {
86+
return this.configList.reduce((result, item) => {
87+
return merge(result, this.analysisWebpackConfig(item));
88+
}, this.webpackConfig);
89+
}
90+
91+
get modules() {
92+
return this.nativeWebpackConfig.resolveLoader.modules;
93+
}
94+
8595
initialize(config) {
8696
this.webpackConfig = this.utils.cloneDeep(require('../config/webpack'));
8797
this.loaders = this.utils.cloneDeep(require('../config/loader'));

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "easywebpack",
3-
"version": "4.0.0-beta.5",
3+
"version": "4.0.0-beta.6",
44
"description": "基于 Webpack 的前端构建工程化解决方案",
55
"keywords": [
66
"webpack",
@@ -37,7 +37,7 @@
3737
"style-loader": "^0.18.2",
3838
"url-loader": "^0.5.8",
3939
"webpack-hot-middleware": "^2.13.2",
40-
"webpack-manifest-resource-plugin": "^2.0.2",
40+
"webpack-manifest-resource-plugin": "next",
4141
"webpack-node-externals": "^1.6.0",
4242
"webpack-tool": "next"
4343
},

0 commit comments

Comments
 (0)