mirror of
https://github.com/grafana/grafana.git
synced 2025-09-18 16:43:50 +08:00
Chore: Add capability for overriding local development behaviour using env vars (#85603)
This commit is contained in:
29
scripts/webpack/env-util.js
Normal file
29
scripts/webpack/env-util.js
Normal file
@ -0,0 +1,29 @@
|
||||
const { parse } = require('ini');
|
||||
const { readFileSync, existsSync } = require('node:fs');
|
||||
|
||||
const getEnvConfig = () => {
|
||||
const defaultSettings = readFileSync(`./conf/defaults.ini`, {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
const customSettings = existsSync(`./conf/custom.ini`)
|
||||
? readFileSync(`./conf/custom.ini`, {
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
: '';
|
||||
|
||||
const defaults = parse(defaultSettings);
|
||||
const custom = parse(customSettings);
|
||||
|
||||
const merged = { ...defaults.frontend_dev, ...custom.frontend_dev };
|
||||
// Take all frontend keys from the ini file and prefix with `frontend_dev_`,
|
||||
// so they can be added to `process.env` elsewhere
|
||||
return Object.entries(merged).reduce((acc, [key, value]) => {
|
||||
return {
|
||||
...acc,
|
||||
[`frontend_dev_${key}`]: value,
|
||||
};
|
||||
}, {});
|
||||
};
|
||||
|
||||
module.exports = getEnvConfig;
|
Reference in New Issue
Block a user