title: How to generate a javascript file with nodeJs
body: <p>My site requires a JSON which I can generate during the build process.</p>
  
  <p>So, what I would like to do is generate a js-file with, for example, the following content:</p>
  
  <pre><code>export const PREFIX = 'foo';
  export const IMPORT_STUFF = {
       a: 10,
       ....
  }
  </code></pre>
  
  <p>The easiest way, for me, would be something like this:</p>
  
  <pre><code>const TEMPLATE = `export PREFIX = '--foo--';
  export const IMPORT_STUFF = `;
  
  let output = TEMPLATE.replace('--foo--', myPefix);
  output += JSON.stringify(importObj);
  
  createJsFile(output);
  </code></pre>
  
  <p>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?</p>