title: Conditional build based on environment using Webpack
body: <p>I have some things for development - e.g mocks which I would like to not bloat my distributed build file with.</p>
  
  <p>In RequireJS you can pass a config in a plugin file and conditonally require things in based on that.</p>
  
  <p>For webpack there doesn't seem to be a way of doing this. Firstly to create a runtime config for an environment I have used <a href="http://webpack.github.io/docs/configuration.html#resolve-alias">resolve.alias</a> to repoint a require depending on the environment, e.g:</p>
  
  <pre><code>// All settings.
  var all = {
      fish: 'salmon'
  };
  
  // `envsettings` is an alias resolved at build time.
  module.exports = Object.assign(all, require('envsettings'));
  </code></pre>
  
  <p>Then when creating the webpack config I can dynamically assign which file <code>envsettings</code> points to (i.e. <code>webpackConfig.resolve.alias.envsettings = './' + env</code>).</p>
  
  <p>However I would like to do something like:</p>
  
  <pre><code>if (settings.mock) {
      // Short-circuit ajax calls.
      // Require in all the mock modules.
  }
  </code></pre>
  
  <p>But obviously I don't want to build in those mock files if the environment isn't mock.</p>
  
  <p>I could possibly manually repoint all those requires to a stub file using resolve.alias again - but is there a way that feels less hacky?</p>
  
  <p>Any ideas how I can do that? Thanks.</p>