title: webpack : is there a good hook / custom function to dump out resolved configuration?
body: <p>I'm somewhat of a newbie with webpack and have been experimenting with easier ways to adjust/merge webpack configurations.</p>
  
  <p>The following code, added to <strong>webpack/lib/webpack.js</strong> has been pretty helpful:</p>
  
  <p>this is the standard webpack.js:</p>
  
  <pre><code>function webpack(options, callback) {
      var compiler;
      if(Array.isArray(options)) {
          compiler = new MultiCompiler(options.map(function(options) {
              return webpack(options);
          }));
      } else if(typeof options === "object") {
          new WebpackOptionsDefaulter().process(options);
  
          compiler = new Compiler();
          compiler.options = options;
          compiler.options = new WebpackOptionsApply().process(options, compiler);
          new NodeEnvironmentPlugin().apply(compiler);
          compiler.applyPlugins("environment");
          compiler.applyPlugins("after-environment");
      } else {
          throw new Error("Invalid argument: options");
      }
      if(callback) {
          if(typeof callback !== "function") throw new Error("Invalid argument: callback");
          if(options.watch === true || (Array.isArray(options) &amp;&amp;
                  options.some(function(o) {
                      return o.watch;
                  }))) {
              var watchOptions = (!Array.isArray(options) ? options : options[0]).watchOptions || {};
              // TODO remove this in next major version
              var watchDelay = (!Array.isArray(options) ? options : options[0]).watchDelay;
              if(watchDelay) {
                  console.warn("options.watchDelay is deprecated: Use 'options.watchOptions.aggregateTimeout' instead");
                  watchOptions.aggregateTimeout = watchDelay;
              }
              return compiler.watch(watchOptions, callback);
          }
          compiler.run(callback);
      }
  </code></pre>
  
  <p>this is my code:</p>
  
  <pre><code>    //customization start
      fs = require('fs');
      var fnp_dump = 'webpack.dump.json';
  
      fs.writeFile(fnp_dump, JSON.stringify(options, null, 2), function(err) {
          if(err) {
              return console.log(err);
          }
          console.log("dumping dump.webpack.js.final.json from webpack.js to: " + fnp_dump);
      }); 
      //customization end
  
  
      return compiler;
  }
  </code></pre>
  
  <p>The basic idea is that it dumps out the final json/js options object <strong>after</strong> webpack has finished sorting out the usual <em>webpack.base.js + webpack.development.js</em>.  Since it's, at that point, just a fully-resolved javascript object, it doesn't really matter how the config.js files were written by individual developers.</p>
  
  <p>Now you can <strong>diff</strong> options sent to webpack (this is an example of tranforming webpack 1 to webpack 2 configurations:</p>
  
  <p><code>diff 003/webpack.dump.json 004/webpack.dump.json</code></p>
  
  <pre><code>&lt;         "loader": "style!css!postcss-loader!sass"
  ---
  &gt;         "use": [
  &gt;           {
  &gt;             "loader": "style-loader"
  &gt;           },
  &gt;           {
  &gt;             "loader": "postcss-loader"
  &gt;           },
  &gt;           {
  &gt;             "loader": "sass-loader"
  &gt;           }
  &gt;         ]
  </code></pre>
  
  <p>However, I am customizing <strong>webpack.js</strong> directly and need to re-apply my patch after each <code>npm update webpack</code>.  Is there a better way?</p>