2014-03-31 17:33:17 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
2017-01-04 15:32:10 +08:00
|
|
|
"use strict";
|
2014-03-31 17:33:17 +08:00
|
|
|
|
2017-01-04 15:32:10 +08:00
|
|
|
const CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning");
|
2014-03-31 17:33:17 +08:00
|
|
|
|
2017-01-04 15:32:10 +08:00
|
|
|
class WarnCaseSensitiveModulesPlugin {
|
|
|
|
apply(compiler) {
|
|
|
|
compiler.plugin("compilation", compilation => {
|
|
|
|
compilation.plugin("seal", function() {
|
|
|
|
const moduleWithoutCase = {};
|
|
|
|
this.modules.forEach(module => {
|
|
|
|
const ident = module.identifier().toLowerCase();
|
|
|
|
if(moduleWithoutCase[`$${ident}`]) {
|
|
|
|
moduleWithoutCase[`$${ident}`].push(module);
|
|
|
|
} else {
|
|
|
|
moduleWithoutCase[`$${ident}`] = [module];
|
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
Object.keys(moduleWithoutCase).forEach(key => {
|
|
|
|
if(moduleWithoutCase[key].length > 1)
|
|
|
|
this.warnings.push(new CaseSensitiveModulesWarning(moduleWithoutCase[key]));
|
|
|
|
}, this);
|
|
|
|
});
|
2014-03-31 17:33:17 +08:00
|
|
|
});
|
2017-01-04 15:32:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = WarnCaseSensitiveModulesPlugin;
|