Skip to content

Commit fd41738

Browse files
test: debug
1 parent 583a9d1 commit fd41738

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

src/utils.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,26 @@ function defaultGetLocalIdent(
6868
localName,
6969
options
7070
) {
71-
const { context, hashPrefix } = options;
71+
let matchResourceRequest;
72+
7273
// eslint-disable-next-line no-underscore-dangle
73-
const { matchResource } = loaderContext._module;
74-
const { resourcePath } = loaderContext;
75-
const request = normalizePath(path.relative(context, resourcePath));
74+
if (loaderContext._module.matchResource) {
75+
matchResourceRequest = normalizePath(
76+
// eslint-disable-next-line no-underscore-dangle
77+
path.relative(options.context, loaderContext._module.matchResource)
78+
);
79+
}
80+
81+
const request = normalizePath(
82+
path.relative(options.context, loaderContext.resourcePath)
83+
);
7684

7785
// eslint-disable-next-line no-param-reassign
7886
options.content = `${
79-
hashPrefix +
80-
(typeof matchResource !== "undefined" ? `${matchResource}\x00` : "") +
87+
options.hashPrefix +
88+
(typeof matchResourceRequest !== "undefined"
89+
? `${matchResourceRequest}\x00`
90+
: "") +
8191
request
8292
}\x00${localName}`;
8393

test/__snapshots__/loader.test.js.snap

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -665,66 +665,66 @@ exports[`loader should work with inline module syntax: result 1`] = `
665665
Array [
666666
Array [
667667
"other.modules.css!=!../../src/index.js?[ident]!./index-loader-syntax.modules.css",
668-
"._3FhluglYfH54WWRd2Lmpsy {
668+
"._14oM7qkZ6dgC62uK5h4NI0 {
669669
color: red;
670670
}
671671
672-
._3danpknEEa0R3CZCkFeRI0 {
672+
._2NqyYysncZeLetATpl0xfW {
673673
color: white;
674674
}",
675675
"",
676676
],
677677
Array [
678678
"button.modules.css!=!./index-loader-syntax-sass.css",
679-
".C6WgXrKWbFsSifATWfzu {
679+
"._8aapa4kQQdSsOoRODcrwe {
680680
width: 5px;
681681
}",
682682
"",
683683
],
684684
Array [
685685
"other.modules.scss!=!../../src/index.js?[ident]!./index-loader-syntax-sass.modules.css",
686-
"._2r_y8mGYyCwfbs1_VPTK5C > ._1yssyumFL0m4gBbuzRhER2 {
686+
"._2yVYVQfmDwKLZn9Qj6k_Q5 > ._3rHlnRnPEotX4nTkd82-aE {
687687
color: red;
688688
}",
689689
"",
690690
],
691691
Array [
692692
"other.modules.css!=!../../src/index.js?[ident]!./index-loader-syntax.modules.css",
693-
"._3FhluglYfH54WWRd2Lmpsy {
693+
"._14oM7qkZ6dgC62uK5h4NI0 {
694694
color: red;
695695
}
696696
697-
._3danpknEEa0R3CZCkFeRI0 {
697+
._2NqyYysncZeLetATpl0xfW {
698698
color: white;
699699
}
700700
701-
._3lQ9E7_p8EySCyfUghDtwz {
701+
._1-Aa1c8UQML46IWY0FjGXT {
702702
from: custom;
703703
}",
704704
"",
705705
],
706706
Array [
707707
"other.modules.css!=!../../src/index.js?[ident]!./index-loader-syntax.modules.css",
708-
"._3FhluglYfH54WWRd2Lmpsy {
708+
"._14oM7qkZ6dgC62uK5h4NI0 {
709709
color: red;
710710
}
711711
712-
._3danpknEEa0R3CZCkFeRI0 {
712+
._2NqyYysncZeLetATpl0xfW {
713713
color: white;
714714
}
715715
716-
._3lQ9E7_p8EySCyfUghDtwz {
716+
._1-Aa1c8UQML46IWY0FjGXT {
717717
from: custom;
718718
}",
719719
"",
720720
],
721721
Array [
722722
"other.modules.scss!=!../../src/index.js?[ident]!./index-loader-syntax-sass.modules.css",
723-
"._2r_y8mGYyCwfbs1_VPTK5C > ._1yssyumFL0m4gBbuzRhER2 {
723+
"._2yVYVQfmDwKLZn9Qj6k_Q5 > ._3rHlnRnPEotX4nTkd82-aE {
724724
color: red;
725725
}
726726
727-
._3B3N-_-uymcqQkGiRwYhjx {
727+
._2kEhhupr-6tgHnCC_d4yO8 {
728728
from: custom;
729729
}",
730730
"",
@@ -738,21 +738,21 @@ Array [
738738
],
739739
Array [
740740
"button.modules.css!=!./index-loader-syntax-sass.css",
741-
".C6WgXrKWbFsSifATWfzu {
741+
"._8aapa4kQQdSsOoRODcrwe {
742742
width: 5px;
743743
}",
744744
"",
745745
],
746746
Array [
747747
"button.module.scss!=!./base64-loader/index.js?[ident]!./simple.js?foo=bar",
748-
"._1Z1CpM4SYZX9egsUO4gNTz {
748+
"._2hfVrRfux-FOrqimHr-fzt {
749749
color: red;
750750
}",
751751
"",
752752
],
753753
Array [
754754
"other.module.scss!=!./base64-loader/index.js?[ident]!./simple.js?foo=baz",
755-
"._1KqQu-H04lA8NLg4-NKnDf {
755+
"._2jOyhMQwdpQ85V5dDLcfoG {
756756
color: red;
757757
}",
758758
"",

0 commit comments

Comments
 (0)