Skip to content

Commit eb08a58

Browse files
fix: context for loader without resource (#409)
1 parent e5d5fd8 commit eb08a58

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/utils.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1169,13 +1169,14 @@ export function getImportCode(html, loaderContext, imports, options) {
11691169
return "";
11701170
}
11711171

1172-
// TODO simplif in the next major release
1172+
// TODO simpify in the next major release
11731173
const getURLRuntime = require.resolve("./runtime/getUrl.js");
1174+
const context = loaderContext.context || loaderContext.rootContext;
11741175
const fileURLToHelper =
11751176
typeof loaderContext.utils !== "undefined" &&
11761177
typeof loaderContext.utils.contextify === "function"
1177-
? loaderContext.utils.contextify(loaderContext.context, getURLRuntime)
1178-
: contextify(loaderContext.context, getURLRuntime);
1178+
? loaderContext.utils.contextify(context, getURLRuntime)
1179+
: contextify(context, getURLRuntime);
11791180

11801181
let code = options.esModule
11811182
? `import ${GET_SOURCE_FROM_IMPORT_NAME} from "${fileURLToHelper}";\n`

0 commit comments

Comments
 (0)