title: combine react build output into single js file
body: <p>This is similar to <a href="https://stackoverflow.com/questions/49123097/generate-single-physical-javascript-file-using-create-react-app">this question</a> however neither of the answers solves the problem.</p>
  
  <p>After running <code>npm run build</code> the resultant <code>index.html</code> looks similar to:</p>
  
  <pre><code>&lt;script&gt;!function (i) { function e(e) { for //rest omitted
  &lt;script src="/static/js/2.3f294f32.chunk.js"&gt;&lt;/script&gt;
  &lt;script src="/static/js/main.7b9daa35.chunk.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>The first <code>&lt;script&gt;</code> element is inlined javascript that i have extracted to a file called <code>loader.js</code></p>
  
  <pre><code>&lt;script src="/loader.js"&gt;&lt;/script&gt;
  &lt;script src="/static/js/2.3f294f32.chunk.js"&gt;&lt;/script&gt;
  &lt;script src="/static/js/main.7b9daa35.chunk.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>this works but I would like to combine <em>all 3 files into a single file</em></p>
  
  <p>I've tried <a href="https://www.filesmerge.com/merge-javascript-files" rel="noreferrer">filesmerge.com</a> to combine the JS files but this results in an error when referencing the single file:</p>
  
  <pre><code>output.min.js:1 Uncaught TypeError: (intermediate value)(...) is not a function
  at output.min.js:1
  </code></pre>
  
  <p>I then tried combining using <a href="https://jscompress.com/" rel="noreferrer">jscompress.com</a> and whilst this does not produce any errors the react root element is not rendered</p>
  
  <p>I've also tried <a href="https://github.com/facebook/create-react-app/issues/3365#issuecomment-376546407" rel="noreferrer">this solution</a> suggested on the create-react-app repo which does not work. No error is produced but no react element is rendered (page remains blank)</p>