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

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

TeldModuleIDWebpackPlugin.prototype.apply=function(compiler) {
        var options = this.options;
        compiler.plugin("compilation", function(compilation) {
            var usedIds = new Set();
            compilation.plugin("before-module-ids", function(modules) {

                for(var index in modules){
                    var module = modules[index]
                    if(module.id === null && module.libIdent) {
                        //console.dir(module)
                        //module.id = module.dependencies[0].module.rawRequest
                        module.id = module.libIdent({
                            context: compiler.options.context
                        });
                    }

                }

            });

        });

    }



module.exports = TeldModuleIDWebpackPlugin;