From 031672b1cd6061da81b14f647a3a78ea4fb3ded8 Mon Sep 17 00:00:00 2001 From: hubcarl Date: Wed, 28 Feb 2018 17:16:13 +0800 Subject: [PATCH] fix: dll resolveLoader.module config for easywebpack in framework --- .gitignore | 1 + lib/base.js | 13 ++++--------- lib/builder.js | 3 ++- lib/config.js | 10 ++++++++++ package.json | 4 ++-- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index b990268..caf6efc 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ coverage.lcov /package-lock.json dist app +.vscode diff --git a/lib/base.js b/lib/base.js index e8f94be..6edf677 100644 --- a/lib/base.js +++ b/lib/base.js @@ -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; } @@ -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)) { @@ -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; } @@ -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 => { @@ -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) { @@ -449,8 +446,6 @@ 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: { @@ -458,7 +453,7 @@ class WebpackBaseBuilder extends 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; diff --git a/lib/builder.js b/lib/builder.js index 7950a6b..d71cbdb 100644 --- a/lib/builder.js +++ b/lib/builder.js @@ -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 = {}; @@ -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()); } diff --git a/lib/config.js b/lib/config.js index 2370eb2..abbb5d8 100644 --- a/lib/config.js +++ b/lib/config.js @@ -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')); diff --git a/package.json b/package.json index 5741879..46dd991 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "easywebpack", - "version": "4.0.0-beta.5", + "version": "4.0.0-beta.6", "description": "基于 Webpack 的前端构建工程化解决方案", "keywords": [ "webpack", @@ -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" },