diff --git a/config/config.json b/config/config.json index f66e271..b97cc8d 100644 --- a/config/config.json +++ b/config/config.json @@ -1,5 +1,6 @@ { "destination": "extensions/config/files/", "minify": false, + "importOnBootstrap": false, "exclude": [] } diff --git a/config/functions/bootstrap.js b/config/functions/bootstrap.js new file mode 100644 index 0000000..db207b5 --- /dev/null +++ b/config/functions/bootstrap.js @@ -0,0 +1,25 @@ +'use strict'; + +const fs = require('fs'); + +/** + * An asynchronous bootstrap function that runs before + * your application gets started. + * + * This gives you an opportunity to set up your data model, + * run jobs, or perform some special logic. + * + * See more details here: https://strapi.io/documentation/v3.x/concepts/configurations.html#bootstrap + */ + +module.exports = () => { + if (strapi.plugins.config.config.importOnBootstrap) { + if (fs.existsSync(strapi.plugins.config.config.destination)) { + const configFiles = fs.readdirSync(strapi.plugins.config.config.destination); + + configFiles.map((file) => { + strapi.plugins.config.services.config.importFromFile(file.slice(0, -5)); + }); + } + } +};