Closed lukakemperle closed 5 months ago
Hi there! Unfortunately there isn't a way to reference variables in the configuration currently.
One solution would be to create a small nodejs script that generates the conf.js
file.
For example, create generateConfig.js
:
const fs = require("fs");
const path = require("path");
const companyName = "Name of the Company";
const signature = "Z lepimi pozdravi / Best regards,";
// Configuration array
const config = [
{
id: "col-1",
companyName,
signature,
name: "Col One",
},
{
id: "col-2",
companyName,
signature,
name: "Col Two",
},
// Add more objects as needed
];
// Function to create a single JSON file with the entire array
function createJsonFile(config) {
const filePath = path.join(__dirname, 'conf.json');
fs.writeFile(filePath, JSON.stringify(config, null, 2), (err) => {
if (err) {
console.error('Error writing file conf.json', err);
} else {
console.log('File conf.json created successfully');
}
});
}
// Run the function
createJsonFile(config);
then run node ./generateConfig.js
to get the desired json.
Hope this helps!
Hey Dan,
I just wanted to say that your idea of creating a separate file for conf.js
is awesome and it has solved all of my problems! Thank you so much for that!
That’s awesome! All the best 🍻
Is it feasible to utilize variables without having to repeat them for each individual _id/colleague? Currently, my config.js file is becoming cluttered due to the repetition with the same information:
I am seeking assistance in implementing a variable system for all signatures, as I currently have to manually repeat the same information with each signature, with only the name changing. -Thank you!