Skip to content

Commit

Permalink
fix(getLocalIdent): add rootContext support (webpack >= v4.0.0) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
yavorsky authored and michael-ciniawsky committed Feb 22, 2018
1 parent 0452f26 commit 9f876d2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/getLocalIdent.js
Expand Up @@ -6,8 +6,15 @@ var loaderUtils = require("loader-utils");
var path = require("path");

module.exports = function getLocalIdent(loaderContext, localIdentName, localName, options) {
if(!options.context)
options.context = loaderContext.options && typeof loaderContext.options.context === "string" ? loaderContext.options.context : loaderContext.context;
if(!options.context) {
if (loaderContext.rootContext) {
options.context = loaderContext.rootContext;
} else if (loaderContext.options && typeof loaderContext.options.context === "string") {
options.context = loaderContext.options.context;
} else {
options.context = loaderContext.context;
}
}
var request = path.relative(options.context, loaderContext.resourcePath);
options.content = options.hashPrefix + request + "+" + localName;
localIdentName = localIdentName.replace(/\[local\]/gi, localName);
Expand Down

0 comments on commit 9f876d2

Please sign in to comment.