/**
 * Created by chendong on 2017/8/14.
 */

var createHash = require("crypto").createHash;

function TeldChunkIDWebpackPlugin(options) {
    this.options = Object.assign({
        hashFunction: "md5",
        hashDigest: "base64",
        hashDigestLength: 4
    }, options);
}

TeldChunkIDWebpackPlugin.prototype.apply=function(compiler) {
    var options = this.options;
    compiler.plugin("compilation", function(compilation) {
        var usedIds = new Set();
        compilation.plugin("before-chunk-ids", function(chunks) {

            for(var index in chunks){
                var chunk = chunks[index]
                if(chunk.id === null ) {
                    chunk.id = chunk.name;
                }

            }

        });

    });

}



module.exports = TeldChunkIDWebpackPlugin;