From e5dfd23d14597b1e44c6c2706af6507fd9a4930e Mon Sep 17 00:00:00 2001 From: Evilebot Tnawi Date: Mon, 11 Mar 2019 20:58:16 +0300 Subject: [PATCH] fix: avoid the "from" argument must be of type string error (#908) --- src/utils.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils.js b/src/utils.js index 6df7ef0f..c647dc82 100644 --- a/src/utils.js +++ b/src/utils.js @@ -6,6 +6,7 @@ import path from 'path'; import cc from 'camelcase'; import loaderUtils from 'loader-utils'; +import normalizePath from 'normalize-path'; /* eslint-disable line-comment-position */ @@ -71,9 +72,9 @@ function getLocalIdent(loaderContext, localIdentName, localName, options) { options.context = loaderContext.rootContext; } - const request = path - .relative(options.context, loaderContext.resourcePath) - .replace(/\\/g, '/'); + const request = normalizePath( + path.relative(options.context || '', loaderContext.resourcePath) + ); // eslint-disable-next-line no-param-reassign options.content = `${options.hashPrefix + request}+${unescape(localName)}`;