diff --git a/docs/source/configuration/environmentvariables.md b/docs/source/configuration/environmentvariables.md index debb468d8f..a63c6144f1 100644 --- a/docs/source/configuration/environmentvariables.md +++ b/docs/source/configuration/environmentvariables.md @@ -175,6 +175,15 @@ You can also generate builds on your continuous integration, then deploy them an yarn BUILD_DIR=dist node dist/server.js ``` + +`VOLTOCONFIG` + This environment variable allows you to specify a custom location for {file}`volto.config.js`. + + It can be relative to the current project or absolute. + + ```shell + VOLTOCONFIG=../../volto.config.js yarn start + ``` ```` diff --git a/docs/source/configuration/volto-config-js.md b/docs/source/configuration/volto-config-js.md index 9320c3c6d5..a33ce66fbf 100644 --- a/docs/source/configuration/volto-config-js.md +++ b/docs/source/configuration/volto-config-js.md @@ -62,3 +62,23 @@ module.exports = { theme }; ``` + +## `VOLTOCONFIG` environment variable usage + +This environment variable allows you to specify a custom location for {file}`volto.config.js`. + +It can be relative to the current project or absolute. + +```shell +VOLTOCONFIG=../../volto.config.js yarn start +``` + +```shell +VOLTOCONFIG=$(pwd)/volto.config.js yarn start +``` + +You can also set it from the root of the monorepo: + +```shell +VOLTOCONFIG=../../volto.config.js pnpm --filter @plone/volto start +``` diff --git a/packages/registry/news/5752.feature b/packages/registry/news/5752.feature new file mode 100644 index 0000000000..37d63a661f --- /dev/null +++ b/packages/registry/news/5752.feature @@ -0,0 +1 @@ +Add `VOLTOCONFIG` environment variable. @sneridagh diff --git a/packages/registry/src/addon-registry.js b/packages/registry/src/addon-registry.js index 418481be76..61980f9928 100644 --- a/packages/registry/src/addon-registry.js +++ b/packages/registry/src/addon-registry.js @@ -98,7 +98,13 @@ class AddonConfigurationRegistry { path.join(projectRootPath, 'package.json'), )); // Loads the dynamic config, if any - if (fs.existsSync(path.join(projectRootPath, 'volto.config.js'))) { + if (process.env.VOLTOCONFIG) { + if (fs.existsSync(path.resolve(process.env.VOLTOCONFIG))) { + const voltoConfigPath = path.resolve(process.env.VOLTOCONFIG); + console.log(`Using volto.config.js in: ${voltoConfigPath}`); + this.voltoConfigJS = require(voltoConfigPath); + } + } else if (fs.existsSync(path.join(projectRootPath, 'volto.config.js'))) { this.voltoConfigJS = require( path.join(projectRootPath, 'volto.config.js'), );