Skip to content

Commit ba5b077

Browse files
fix: the auto option for inline module syntax
1 parent c13f369 commit ba5b077

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

src/utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ const moduleRegExp = /\.module(s)?\.\w+$/i;
126126
const icssRegExp = /\.icss\.\w+$/i;
127127

128128
function getModulesOptions(rawOptions, loaderContext) {
129-
const { resourcePath } = loaderContext;
129+
const resourcePath =
130+
// eslint-disable-next-line no-underscore-dangle
131+
loaderContext._module.matchResource || loaderContext.resourcePath;
132+
130133
let isIcss;
131134

132135
if (typeof rawOptions.modules === "undefined") {

test/__snapshots__/loader.test.js.snap

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,8 @@ Array [
675675
"",
676676
],
677677
Array [
678-
"plain.scss!=!../../src/index.js?[ident]!./index-loader-syntax-sass.css",
679-
".baz {
678+
"button.modules.css!=!./index-loader-syntax-sass.css",
679+
".iuzmhXWrT3_Z-zKS-rMGM {
680680
width: 5px;
681681
}",
682682
"",
@@ -733,6 +733,20 @@ Array [
733733
"./index-loader-syntax.css",
734734
".a {
735735
color: red;
736+
}",
737+
"",
738+
],
739+
Array [
740+
"button.modules.css!=!./index-loader-syntax-sass.css",
741+
".iuzmhXWrT3_Z-zKS-rMGM {
742+
width: 5px;
743+
}",
744+
"",
745+
],
746+
Array [
747+
"button.module.scss!=!./base64-loader/index.js?[ident]!./simple.js",
748+
"._1DaPRMj4jImbX3XSIzjaR4 {
749+
color: red;
736750
}",
737751
"",
738752
],

test/fixtures/base64-loader/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = function loader(content) {
2+
return Buffer.from(this.query.slice(1), 'base64').toString('ascii');
3+
};

test/fixtures/index-loader-syntax.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import css from './index-loader-syntax.css';
1+
import one from './index-loader-syntax.css';
2+
import two from 'button.modules.css!=!./index-loader-syntax-sass.css';
3+
import three from './button.module.scss!=!./base64-loader?LmZvbyB7IGNvbG9yOiByZWQ7IH0=!./simple.js';
24

3-
__export__ = css;
5+
__export__ = [...one, ...two, ...three];
46

5-
export default css;
7+
export default [...one, ...two, ...three];

0 commit comments

Comments
 (0)