From fcc1a74ce36936c8f08fe89897cc0e2611f52632 Mon Sep 17 00:00:00 2001 From: dmbch Date: Mon, 5 Feb 2018 11:23:32 +0100 Subject: [PATCH] fix(config): fix config extension mechanism --- packages/config/index.js | 41 +++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/packages/config/index.js b/packages/config/index.js index 5f53aa03f..01fe5d889 100644 --- a/packages/config/index.js +++ b/packages/config/index.js @@ -8,22 +8,25 @@ var root = require('pkg-dir').sync(); var cosmiconfig = require('cosmiconfig'); -function getDefaultConfig() { - return { - https: false, - host: '0.0.0.0', - port: 8080, - locations: [], - basePath: '', - assetPath: '', - browsers: '> 1%, last 2 versions, Firefox ESR', - node: 'current', - envVars: { HOPS_MODE: 'dynamic' }, - moduleDirs: [], - appDir: '.', - buildDir: 'build', - cacheDir: 'node_modules/.cache/hops', - }; +function applyDefaultConfig(config) { + return assign( + { + https: false, + host: '0.0.0.0', + port: 8080, + locations: [], + basePath: '', + assetPath: '', + browsers: '> 1%, last 2 versions, Firefox ESR', + node: 'current', + envVars: { HOPS_MODE: 'dynamic' }, + moduleDirs: [], + appDir: '.', + buildDir: 'build', + cacheDir: 'node_modules/.cache/hops', + }, + config + ); } function applyUserConfig(config) { @@ -53,7 +56,7 @@ function applyInheritedConfig(config) { sync: true, }); var _result = loader.load(); - assign(result, assign(_result ? _result.config : {}, result)); + result = assign(_result ? _result.config : {}, result); } else { console.error('Failed to load inherited config', configName); } @@ -126,13 +129,13 @@ function normalizeURLs(config) { } module.exports = [ - getDefaultConfig, applyUserConfig, applyInheritedConfig, applyEnvironmentConfig, + applyDefaultConfig, resolvePlaceholders, resolvePaths, normalizeURLs, ].reduce(function(result, step) { return step(result); -}, null); +}, {});