Skip to content

Commit 9f876d2

Browse files
yavorskymichael-ciniawsky
authored andcommitted
fix(getLocalIdent): add rootContext support (webpack >= v4.0.0) (#681)
1 parent 0452f26 commit 9f876d2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/getLocalIdent.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ var loaderUtils = require("loader-utils");
66
var path = require("path");
77

88
module.exports = function getLocalIdent(loaderContext, localIdentName, localName, options) {
9-
if(!options.context)
10-
options.context = loaderContext.options && typeof loaderContext.options.context === "string" ? loaderContext.options.context : loaderContext.context;
9+
if(!options.context) {
10+
if (loaderContext.rootContext) {
11+
options.context = loaderContext.rootContext;
12+
} else if (loaderContext.options && typeof loaderContext.options.context === "string") {
13+
options.context = loaderContext.options.context;
14+
} else {
15+
options.context = loaderContext.context;
16+
}
17+
}
1118
var request = path.relative(options.context, loaderContext.resourcePath);
1219
options.content = options.hashPrefix + request + "+" + localName;
1320
localIdentName = localIdentName.replace(/\[local\]/gi, localName);

0 commit comments

Comments
 (0)