My site requires a JSON which I can generate during the build process.
So, what I would like to do is generate a js-file with, for example, the following content:
export const PREFIX = 'foo';
export const IMPORT_STUFF = {
a: 10,
....
}
The easiest way, for me, would be something like this:
const TEMPLATE = `export PREFIX = '--foo--';
export const IMPORT_STUFF = `;
let output = TEMPLATE.replace('--foo--', myPefix);
output += JSON.stringify(importObj);
createJsFile(output);
When things get more complex I can imagine that this approach is not ideal, so I was wondering if there are better ways to do something like this?