Extracting common chunks amongst multiple compiler configurations in webpack?
<p>I'm trying out the multi-compiler option in webpack and am following the <a href="https://github.com/webpack/webpack/tree/master/examples/multi-compiler" rel="noreferrer">example</a> at their github. However, I can't seem to understand how I can split out the common code amongst the multiple configurations. </p>

<p>For example, I may have same vendor libraries used in the different set of configurations. I would like to have these shared codes to be bundled to one single common file.</p>

<p>I tried the following but it ended up creating an individual bundles of the <code>vendors</code> entry for each compile configuration.</p>

<pre><code>var path = require("path");
var webpack = require("webpack");
module.exports = [
    {
        name: "app-mod1",
        entry: {
            vendors: ['jquery', 'react', 'react-dom'],
            pageA: ['./mod1/pageA'],
            pageB: ['./mod1/pageB']
        },
        output: {
            path: path.join(__dirname, "/mod1/js"),
            filename: "[name].bundle.js"
        },
        plugins: [
            new webpack.optimize.CommonsChunkPlugin({
                names: ['vendors'],
                minChunks: Infinity
            })
        ]
    },
    {
        name: "app-mod2",
        entry: {
            vendors: ['lodash', 'react', 'react-dom'],
            pageA: ['./mod2/pageA'],
            pageB: ['./mod2/pageB']
        },
        output: {
            path: path.join(__dirname, "/mod2/js"),
            filename: "[name].bundle.js"
        },
        plugins: [
            new webpack.optimize.CommonsChunkPlugin({
                names: ['vendors'],
                minChunks: Infinity
            })
        ]
    }
];
</code></pre>

<p>Since react, react-dom are shared between the 2 compilations, my intention is for them to be bundled as a single file which can be shared instead of creating a same bundle for each compilation.</p>

<p>How can I extract the common chunks out of multiple compiler configurations?</p>