With default build settings I get following build layers: (X+A), (Y+A+B), (Z+B).
I want: (X+A), (Y+A), Z, B
B should load only once when we asking Y and Z modules.
I found CommonsChunkPlugin, but I cant configure it properly.
var webpack = require("webpack");
var CommonsPlugin = new require("webpack/lib/optimize/CommonsChunkPlugin");
module.exports = {
    entry: {
        main: "./main"
    },
    resolve: {
        modulesDirectories: [
            "."
        ]
    },
    output: {
        publicPath: "js/",
        filename: "[name].builded.js"
    },
    plugins: [
           new CommonsPlugin({
            //  What should I write here?
            })
    ]
};

 
                        
Looks like you should add
Bas separate entry point:and add CommonsChunkPlugin in
pluginssection: