Skip to content

Commit 31c4cdc

Browse files
committed
Add ident to loaders passed to child compilation
add test case how css deduplication works
1 parent 347d725 commit 31c4cdc

File tree

7 files changed

+56
-0
lines changed

7 files changed

+56
-0
lines changed

src/loader.js

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export function pitch(request) {
5151
return ({
5252
loader: loader.path,
5353
options: loader.options,
54+
ident: loader.ident,
5455
});
5556
});
5657
}

test/cases/composes-async/async-1.css

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:local .base {
2+
composes: composed from './async-2.css';
3+
background: blue;
4+
}

test/cases/composes-async/async-2.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:local .composed {
2+
background: green;
3+
}
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.base {
2+
background: blue;
3+
}
4+
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.composed {
2+
background: green;
3+
}
4+

test/cases/composes-async/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import('./async-1.css');
2+
import('./async-2.css');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const Self = require('../../../');
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+
localIdentName: '[local]'
15+
}
16+
}
17+
],
18+
},
19+
],
20+
},
21+
optimization: {
22+
splitChunks: {
23+
cacheGroups: {
24+
cssDedupe: {
25+
test: /\.css$/,
26+
chunks: 'all',
27+
minChunks: 2,
28+
enforce: true
29+
}
30+
}
31+
}
32+
},
33+
plugins: [
34+
new Self({
35+
filename: '[name].css',
36+
}),
37+
],
38+
};

0 commit comments

Comments
 (0)