Skip to content

Commit ee411f0

Browse files
committed
fix: include matchResource in entry request
1 parent 6ae4c3e commit ee411f0

File tree

7 files changed

+90
-18971
lines changed

7 files changed

+90
-18971
lines changed

package-lock.json

+44-18,968
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"babel-jest": "^26.6.3",
5858
"bootstrap": "^4.6.0",
5959
"cross-env": "^7.0.3",
60-
"css-loader": "^5.0.2",
60+
"css-loader": "^5.1.3",
6161
"del": "^6.0.0",
6262
"del-cli": "^3.0.1",
6363
"es-check": "5.2.0",

src/loader.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ export function pitch(request) {
9292

9393
const { EntryOptionPlugin } = webpack;
9494

95+
let entryRequest = `!!${request}`;
96+
if (typeof this._module.matchResource !== 'undefined') {
97+
entryRequest = `${this._module.matchResource}!=!${entryRequest}`;
98+
}
99+
95100
if (EntryOptionPlugin) {
96101
const {
97102
library: { EnableLibraryPlugin },
@@ -104,14 +109,14 @@ export function pitch(request) {
104109
library: {
105110
type: 'commonjs2',
106111
},
107-
import: [`!!${request}`],
112+
import: [entryRequest],
108113
},
109114
});
110115
} else {
111116
const { LibraryTemplatePlugin, SingleEntryPlugin } = webpack;
112117

113118
new LibraryTemplatePlugin(null, 'commonjs2').apply(childCompiler);
114-
new SingleEntryPlugin(this.context, `!!${request}`, pluginName).apply(
119+
new SingleEntryPlugin(this.context, entryRequest, pluginName).apply(
115120
childCompiler
116121
);
117122
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = function base64Loader() {
2+
return Buffer.from(this.query.slice(1), 'base64').toString('ascii');
3+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.index__foo__3o8gA { color: red; }
2+
.index__foo__3wlgf { color: red; }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* eslint-disable */
2+
3+
import styles from './foo.module.css!=!./base64-loader?LmZvbyB7IGNvbG9yOiByZWQ7IH0=!./index.js?foo';
4+
import styles2 from './baz.module.css!=!./base64-loader?LmZvbyB7IGNvbG9yOiByZWQ7IH0=!./index.js?bar';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Self from '../../../src';
2+
3+
module.exports = {
4+
entry: './index.js',
5+
module: {
6+
rules: [
7+
{
8+
test: /\.css$/,
9+
use: [
10+
Self.loader,
11+
{
12+
loader: 'css-loader',
13+
options: {
14+
modules: {
15+
auto: true,
16+
localIdentName: '[name]__[local]__[hash:base64:5]',
17+
},
18+
},
19+
},
20+
],
21+
},
22+
],
23+
},
24+
plugins: [
25+
new Self({
26+
filename: '[name].css',
27+
}),
28+
],
29+
};

0 commit comments

Comments
 (0)