title: javascript: conditionally including test files
body: <p>I have inherited a webapp project that is a single html page with JQuery + extra javascript files that are imported into the main app.js. The webapp is intended to be embedded in our main application.</p>
  
  <p>The webapp is distributed through a webpack configuration that builds a bundle.js from all the javascript files and add the html and css file separately due to requirements of the main application.</p>
  
  <p>All this works well, except that, to test the webapp stand-alone, we include testdata in the app.js.</p>
  
  <pre><code>import td from ./testdata.js
  
  if ([we are in the main application]) {
     // do whatever necessary to start the webapp
  }
  else {
    // standalone
    let testdata = td.getTestdata();
    // start webapp
  }
  </code></pre>
  
  <p>In the production version I want to prevent the testdata to be bundled with the  bundle.js.</p>
  
  <p>I have tried to import the testdata.js in the else clause, but that resolves in an error.</p>
  
  <p>I have tried to overwrite the testdata.js with an empty one, but that needs to be done in the webpack config and I cannot find where to add a 'pre bundle' action.</p>
  
  <p>What is the best approach to handle this?</p>