Support config-local.json overrides config.json

This commit is contained in:
2017-06-30 21:02:09 -07:00
parent f370d7674e
commit cc41cc1e3b
3 changed files with 18 additions and 1 deletions

1
.gitignore vendored
View File

@@ -6,3 +6,4 @@ node_modules
npm-debug.log
yarn-error.log
vendor
resources/assets/config-local.json

View File

@@ -2,7 +2,9 @@ const path = require('path');
const { argv } = require('yargs');
const merge = require('webpack-merge');
const userConfig = require('../config');
const desire = require('./util/desire');
const userConfig = merge(desire(`${__dirname}/../config`), desire(`${__dirname}/../config-local`));
const isProduction = !!((argv.env && argv.env.production) || argv.p);
const rootPath = (userConfig.paths && userConfig.paths.root)

View File

@@ -0,0 +1,14 @@
/**
* @export
* @param {string} dependency
* @param {any} [fallback]
* @return {any}
*/
module.exports = (dependency, fallback) => {
try {
require.resolve(dependency);
} catch (err) {
return fallback;
}
return require(dependency); // eslint-disable-line import/no-dynamic-require
};