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 => {
|
2017-01-06 19:56:00 +08:00
|
|
|
compilation.plugin("seal", () => {
|
|
|
|
const moduleWithoutCase = Object.create(null);
|
|
|
|
compilation.modules.forEach(module => {
|
2017-01-05 19:12:15 +08:00
|
|
|
const identifier = module.identifier().toLowerCase();
|
2017-01-06 19:56:00 +08:00
|
|
|
if(moduleWithoutCase[identifier]) {
|
|
|
|
moduleWithoutCase[identifier].push(module);
|
2017-01-04 15:32:10 +08:00
|
|
|
} else {
|
2017-01-06 19:56:00 +08:00
|
|
|
moduleWithoutCase[identifier] = [module];
|
2017-01-04 15:32:10 +08:00
|
|
|
}
|
2017-01-05 19:12:15 +08:00
|
|
|
});
|
2017-01-04 15:32:10 +08:00
|
|
|
Object.keys(moduleWithoutCase).forEach(key => {
|
2017-01-06 19:56:00 +08:00
|
|
|
if(moduleWithoutCase[key].length > 1)
|
|
|
|
compilation.warnings.push(new CaseSensitiveModulesWarning(moduleWithoutCase[key]));
|
|
|
|
});
|
2017-01-04 15:32:10 +08:00
|
|
|
});
|
2014-03-31 17:33:17 +08:00
|
|
|
});
|
2017-01-04 15:32:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = WarnCaseSensitiveModulesPlugin;
|