From ac5c211e5b03bbc222385d57832e522a7287ebea Mon Sep 17 00:00:00 2001 From: chencheng Date: Fri, 1 Jun 2018 11:44:49 +0800 Subject: [PATCH 1/2] fix(umi-build-dev): config change don't update service's config --- packages/umi-build-dev/src/Service.js | 1 + packages/umi-build-dev/src/UserConfig.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/packages/umi-build-dev/src/Service.js b/packages/umi-build-dev/src/Service.js index b39d885727a5..a962a98de5c9 100644 --- a/packages/umi-build-dev/src/Service.js +++ b/packages/umi-build-dev/src/Service.js @@ -224,6 +224,7 @@ export default class Service { console.error(chalk.red(e.message)); process.exit(1); } + this._initialConfig = config; this.config = new Proxy(config, { set: (target, name, value) => { target[name] = value; diff --git a/packages/umi-build-dev/src/UserConfig.js b/packages/umi-build-dev/src/UserConfig.js index c328ec91300f..7fb7b99499a1 100644 --- a/packages/umi-build-dev/src/UserConfig.js +++ b/packages/umi-build-dev/src/UserConfig.js @@ -252,9 +252,12 @@ class UserConfig { const oldConfig = clone(this.config); this.config = newConfig; + for (const plugin of this.plugins) { const { name } = plugin; if (!isEqual(newConfig[name], oldConfig[name])) { + this.service._initialConfig[name] = newConfig[name]; + this.service.config[name] = newConfig[name]; if (plugin.onChange) { plugin.onChange(newConfig); } From 8df074e94a86784eb1c7036df1d53cdf171196a1 Mon Sep 17 00:00:00 2001 From: chencheng Date: Fri, 1 Jun 2018 14:29:52 +0800 Subject: [PATCH 2/2] fix: initial config dont updated --- packages/umi-build-dev/package.json | 1 + packages/umi-build-dev/src/Service.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/packages/umi-build-dev/package.json b/packages/umi-build-dev/package.json index 70aead435aa1..649c9ee5409c 100644 --- a/packages/umi-build-dev/package.json +++ b/packages/umi-build-dev/package.json @@ -25,6 +25,7 @@ "lodash.isequal": "^4.5.0", "lodash.remove": "^4.7.0", "mkdirp": "^0.5.1", + "object-assign": "^4.1.1", "path-is-absolute": "^1.0.1", "postcss-plugin-px2rem": "^0.7.0", "preact": "^8.2.5", diff --git a/packages/umi-build-dev/src/Service.js b/packages/umi-build-dev/src/Service.js index a962a98de5c9..909739d1a01b 100644 --- a/packages/umi-build-dev/src/Service.js +++ b/packages/umi-build-dev/src/Service.js @@ -7,6 +7,7 @@ import getWebpackRCConfig, { } from 'af-webpack/getUserConfig'; import { clearConsole } from 'af-webpack/react-dev-utils'; import chalk from 'chalk'; +import assign from 'object-assign'; import getPaths from './getPaths'; import getRouteConfig from './routes/getRouteConfig'; import registerBabel from './registerBabel'; @@ -81,6 +82,7 @@ export default class Service { const userConfig = new UserConfig(this); try { this.config = userConfig.getConfig({ force: true }); + assign(this._initialConfig, this.config); } catch (e) { console.error(chalk.red(e.message)); debug('Get config failed, watch config and reload');