mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 06:04:29 +00:00
Take advantage of multiple environment config
This commit is contained in:
parent
fefdc4cf9b
commit
6cbd45e680
@ -59,8 +59,19 @@ module.exports = function (strapi) {
|
||||
}, cb);
|
||||
},
|
||||
|
||||
// Load environment-specific config from `./config/environments/**/*.js|json`.
|
||||
// Load all environments config from `./config/environments/*/*.js|json`.
|
||||
// Not really used inside the framework but useful for the Studio.
|
||||
'config/environments/**': function (cb) {
|
||||
dictionary.optional({
|
||||
dirname: path.resolve(strapi.config.appPath, strapi.config.paths.config, 'environments'),
|
||||
filter: /(.+)\.(js|json)$/,
|
||||
identity: false,
|
||||
depth: 4
|
||||
}, cb);
|
||||
},
|
||||
|
||||
// Load environment-specific config from `./config/environments/**/*.js|json`.
|
||||
'config/environments/*': function (cb) {
|
||||
dictionary.aggregate({
|
||||
dirname: path.resolve(strapi.config.appPath, strapi.config.paths.config, 'environments', strapi.config.environment),
|
||||
filter: /(.+)\.(js|json)$/,
|
||||
@ -90,7 +101,7 @@ module.exports = function (strapi) {
|
||||
// Merge every user config together.
|
||||
const mergedConfig = _.merge(
|
||||
config['config/*'],
|
||||
config['config/environments/**'],
|
||||
config['config/environments/*'],
|
||||
config['config/functions/*']
|
||||
);
|
||||
|
||||
@ -119,8 +130,8 @@ module.exports = function (strapi) {
|
||||
const ormConfig = JSON.parse(fs.readFileSync(path.resolve(strapi.config.appPath, strapi.config.paths.config, 'environments', strapi.config.environment, 'databases.json')));
|
||||
strapi.config.orm = ormConfig.orm;
|
||||
|
||||
// Save different environments inside an array because we need it in the Strapi Studio.
|
||||
strapi.config.environments = fs.readdirSync(path.resolve(strapi.config.appPath, strapi.config.paths.config, 'environments'));
|
||||
// Save different environments because we need it in the Strapi Studio.
|
||||
strapi.config.environments = config['config/environments/**'] || {};
|
||||
|
||||
// Make the application name in config match the server one.
|
||||
strapi.app.name = strapi.config.name;
|
||||
|
||||
@ -98,7 +98,7 @@ module.exports = function (strapi) {
|
||||
def.config = def.config || {};
|
||||
|
||||
// List of environments to run in, if empty defaults to all.
|
||||
def.config.environments = def.config.environments || [];
|
||||
def.config.environments = def.config.environments || {};
|
||||
|
||||
return def;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user