Skip to content

Commit

Permalink
fix: dll resolveLoader.module config for easywebpack in framework
Browse files Browse the repository at this point in the history
  • Loading branch information
hubcarl committed Feb 28, 2018
1 parent 7ff4a01 commit 031672b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ coverage.lcov
/package-lock.json
dist
app
.vscode
13 changes: 4 additions & 9 deletions lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,8 @@ class WebpackBaseBuilder extends Config {

installLoader(loaders) {
const dependencies = this.dependencies;
const modules = this.webpackConfig.resolveLoader && this.webpackConfig.resolveLoader.modules;
const webpackLoaders = this.createLoader(loaders);
this.utils.installLoader(webpackLoaders, dependencies, modules, this.config.install);
this.utils.installLoader(webpackLoaders, dependencies, this.modules, this.config.install);
return webpackLoaders;
}

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

createPlugin(plugins) {
const webpackPlugins = [];
const modules = this.webpackConfig.resolveLoader && this.webpackConfig.resolveLoader.modules;
Object.keys(plugins).forEach(name => {
const configInfo = plugins[name];
if (this.isUse(configInfo)) {
Expand All @@ -351,7 +349,7 @@ class WebpackBaseBuilder extends Config {
let Clazz = configInfo.name;
if (this.utils.isString(configInfo.name)) {
pluginName = configInfo.name;
Clazz = this.utils.requireModule(configInfo.name, modules);
Clazz = this.utils.requireModule(configInfo.name, this.modules);
} else if (this.utils.isFunction(configInfo.name)) {
pluginName = configInfo.name.name;
}
Expand All @@ -377,7 +375,6 @@ class WebpackBaseBuilder extends Config {
}

installPlugin(plugins) {
const modules = this.webpackConfig.resolveLoader && this.webpackConfig.resolveLoader.modules;
const dependencies = this.dependencies;
const enablePlugins = {};
Object.keys(plugins).forEach(name => {
Expand All @@ -386,7 +383,7 @@ class WebpackBaseBuilder extends Config {
enablePlugins[name] = pluginInfo;
}
});
return this.utils.installPlugin(enablePlugins, dependencies, modules, this.config.install);
return this.utils.installPlugin(enablePlugins, dependencies, this.modules, this.config.install);
}

adapterPlugin(plugins) {
Expand Down Expand Up @@ -449,16 +446,14 @@ class WebpackBaseBuilder extends Config {

combineWebpackConfig(config) {
this.t3 = Date.now();
const outerWebpackConfig = this.analysisWebpackConfig(config);
const configWebpackConfig = this.mergeWebpackConfig(this.webpackConfig, outerWebpackConfig);
const buildWebpackConfig = {
output: this.createOutput(config),
module: {
rules: this.createWebpackLoader(config)
},
plugins: this.createWebpackPlugin(config)
};
const webpackConfig = this.mergeWebpackConfig(configWebpackConfig, buildWebpackConfig);
const webpackConfig = this.mergeWebpackConfig(this.nativeWebpackConfig, buildWebpackConfig);
this.t4 = Date.now();
this.logger.cost();
return webpackConfig;
Expand Down
3 changes: 2 additions & 1 deletion lib/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ exports.getDllWebpackConfig = (config, option = {}) => {
const publicPath = config.publicPath;
const buildPath = config.buildPath;
const install = config.install;
const resolveLoader = config.resolveLoader;
const cdn = config.cdn;
const configPlugins = config.plugins || {};
const plugins = {};
Expand All @@ -49,7 +50,7 @@ exports.getDllWebpackConfig = (config, option = {}) => {
}
}
dllArray.forEach(item => {
const builderConfig = Object.assign({}, dllConfig, { entry: {}, dll: item, publicPath, buildPath, alias, externals, install, cdn, plugins }, item.webpackConfig);
const builderConfig = Object.assign({}, dllConfig, { entry: {}, dll: item, publicPath, buildPath, alias, externals, resolveLoader, install, cdn, plugins }, item.webpackConfig);
if (option.onlyView || utils.checkDllUpdate(config, item)) {
dllWebpackConfig.push(new WebpackDllBuilder(builderConfig).create());
}
Expand Down
10 changes: 10 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ class Config {
return this.dev && this.utils.isTrue(config.proxy);
}

get nativeWebpackConfig() {
return this.configList.reduce((result, item) => {
return merge(result, this.analysisWebpackConfig(item));
}, this.webpackConfig);
}

get modules() {
return this.nativeWebpackConfig.resolveLoader.modules;
}

initialize(config) {
this.webpackConfig = this.utils.cloneDeep(require('../config/webpack'));
this.loaders = this.utils.cloneDeep(require('../config/loader'));
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "easywebpack",
"version": "4.0.0-beta.5",
"version": "4.0.0-beta.6",
"description": "基于 Webpack 的前端构建工程化解决方案",
"keywords": [
"webpack",
Expand Down Expand Up @@ -37,7 +37,7 @@
"style-loader": "^0.18.2",
"url-loader": "^0.5.8",
"webpack-hot-middleware": "^2.13.2",
"webpack-manifest-resource-plugin": "^2.0.2",
"webpack-manifest-resource-plugin": "next",
"webpack-node-externals": "^1.6.0",
"webpack-tool": "next"
},
Expand Down

0 comments on commit 031672b

Please sign in to comment.