Forked from alexkirsz/ForceCaseSensitivityPlugin.js
Created
October 29, 2015 20:55
-
-
Save pthrasher/7e7aa8bc51a794d6750f to your computer and use it in GitHub Desktop.
Force case sensitivity in webpack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var path = require('path'); | |
var _ = require('lodash'); | |
module.exports = function ForceCaseSensitivityPlugin() { | |
this.plugin('normal-module-factory', function(nmf) { | |
nmf.plugin('after-resolve', function(data, done) { | |
var parentDir = path.dirname(data.resource); | |
var resourceName = path.basename(data.resource); | |
fs.readdir(parentDir, function(err, files) { | |
if (err) { | |
done(err); | |
} | |
if (files.indexOf(resourceName) === -1) { | |
var realName = _.find(files, function(filename) { | |
return filename.toLowerCase() === resourceName.toLowerCase() | |
}); | |
done(new Error('ForceCaseSensitivityPlugin: `' + resourceName + '` does not match the corresponding file on disk `' + realName + '`')); | |
return; | |
} | |
done(null, data); | |
}); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment