Skip to content

Commit d7946d0

Browse files
lfreevilebottnawi
authored andcommitted
fix(index): assign empty module.id to prevent contenthash from changing unnecessarily (#284)
* fix: add empty id to prevent contenthash from changing unnecessarily * fix: updated tests
1 parent aa993da commit d7946d0

11 files changed

+6
-9
lines changed

src/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class CssDependencyTemplate {
4242
class CssModule extends webpack.Module {
4343
constructor(dependency) {
4444
super(MODULE_TYPE, dependency.context);
45+
this.id = '';
4546
this._identifier = dependency.identifier;
4647
this._identifierIndex = dependency.identifierIndex;
4748
this.content = dependency.content;
@@ -92,7 +93,7 @@ class CssModule extends webpack.Module {
9293
super.updateHash(hash);
9394
hash.update(this.content);
9495
hash.update(this.media || '');
95-
hash.update(JSON.stringify(this.sourceMap || ''));
96+
hash.update(this.sourceMap ? JSON.stringify(this.sourceMap) : '');
9697
}
9798
}
9899

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

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

test/cases/contenthash-multiple-entries/expected/7bb844e9f5514d392e40.css

-4
This file was deleted.

0 commit comments

Comments
 (0)