Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: module identifier, don't merge modules with different media/suppors/layer #1021

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class MiniCssExtractPlugin {
}

identifier() {
return `css|${this._identifier}|${this._identifierIndex}`;
return `css|${this._identifier}|${this._identifierIndex}|${this.layer}|${this.supports}|${this.media}}}`;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions test/cases/issue-css-loader-1503-1/dark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: black;
}
4 changes: 4 additions & 0 deletions test/cases/issue-css-loader-1503-1/expected/dark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
background: black;
}

8 changes: 8 additions & 0 deletions test/cases/issue-css-loader-1503-1/expected/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@supports (display: flex) {
body {
background: black;
}

}


1 change: 1 addition & 0 deletions test/cases/issue-css-loader-1503-1/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import url("dark.css") supports(display: flex);
31 changes: 31 additions & 0 deletions test/cases/issue-css-loader-1503-1/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Self from "../../../src";

module.exports = {
entry: {
dark: "./dark.css",
index: "./index.css",
},
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: Self.loader,
},
{
loader: "css-loader",
options: {
modules: true,
},
},
],
},
],
},
plugins: [
new Self({
filename: "[name].css",
}),
],
};
3 changes: 3 additions & 0 deletions test/cases/issue-css-loader-1503-2/dark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: black;
}
4 changes: 4 additions & 0 deletions test/cases/issue-css-loader-1503-2/expected/dark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
background: black;
}

8 changes: 8 additions & 0 deletions test/cases/issue-css-loader-1503-2/expected/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@layer framework.component {
body {
background: black;
}

}


1 change: 1 addition & 0 deletions test/cases/issue-css-loader-1503-2/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import url("dark.css") layer(framework.component);
31 changes: 31 additions & 0 deletions test/cases/issue-css-loader-1503-2/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Self from "../../../src";

module.exports = {
entry: {
dark: "./dark.css",
index: "./index.css",
},
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: Self.loader,
},
{
loader: "css-loader",
options: {
modules: true,
},
},
],
},
],
},
plugins: [
new Self({
filename: "[name].css",
}),
],
};
3 changes: 3 additions & 0 deletions test/cases/issue-css-loader-1503/dark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: black;
}
4 changes: 4 additions & 0 deletions test/cases/issue-css-loader-1503/expected/dark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
background: black;
}

8 changes: 8 additions & 0 deletions test/cases/issue-css-loader-1503/expected/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@media (prefers-color-scheme: dark) {
body {
background: black;
}

}


1 change: 1 addition & 0 deletions test/cases/issue-css-loader-1503/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "./dark.css" (prefers-color-scheme: dark);
31 changes: 31 additions & 0 deletions test/cases/issue-css-loader-1503/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Self from "../../../src";

module.exports = {
entry: {
dark: "./dark.css",
index: "./index.css",
},
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: Self.loader,
},
{
loader: "css-loader",
options: {
modules: true,
},
},
],
},
],
},
plugins: [
new Self({
filename: "[name].css",
}),
],
};