title: Webpack externals Module not found
body: <p>Hello hope you are well. </p>
  
  <p>I am currently struggling with webpack a bit and was looking for the best solution to cater for the following : </p>
  
  <p>I want to load config from json from my single page app and use it wherever. This actually works well :</p>
  
  <pre><code>externals: {
      'config': JSON.stringify(getAppConfig())
  }
  </code></pre>
  
  <p>This is of course added into webpack config and getAppConfig is: </p>
  
  <pre><code>var getAppConfig = () =&gt; {
      var finalConfig = require('./config.json');
      if (process.argv.indexOf('--env.production')) {
          finalConfig = Object.assign(finalConfig, require('./config.production.json'));
      }
      /*more stuff here but removed for simplicity*/
      return finalConfig;
  }
  </code></pre>
  
  <p>Then inside a module, I do </p>
  
  <pre><code>import Config from 'config';
  </code></pre>
  
  <p>And use the imported javascript object. Surprisingly everything works as expected :) My problem actually is this ugly error in webpack</p>
  
  <pre><code>ERROR in ./ClientApp/store/WeatherForecasts.ts 
  Module not found: Error: Cannot resolve module 'config' in
  </code></pre>
  
  <p>I really don't want to have fake errors for CI purposes and what not, but I would much rather understand what's going on than just ignore it somehow. Btw, I am using typescript for the project, not sure if it changes anything but best to state all the facts I guess. This is the typescript module definition :</p>
  
  <pre><code>declare module 'config' {
      export interface Config {
          backendUrl: string;
      }
      export default {} as Config;
  }
  </code></pre>
  
  <p>All help much appreciated.
  Peter</p>