Skip to content
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
12 changes: 11 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -991,16 +991,22 @@ class MiniCssExtractPlugin {
const readableIdentifier = module.readableIdentifier(requestShortener);
const startsWithAtRuleImport = /^@import url/.test(content);

let header;

if (compilation.outputOptions.pathinfo) {
// From https://github.com/webpack/webpack/blob/29eff8a74ecc2f87517b627dee451c2af9ed3f3f/lib/ModuleInfoHeaderPlugin.js#L191-L194
const reqStr = readableIdentifier.replace(/\*\//g, "*_/");
const reqStrStar = "*".repeat(reqStr.length);
const headerStr = `/*!****${reqStrStar}****!*\\\n !*** ${reqStr} ***!\n \\****${reqStrStar}****/\n`;

content = headerStr + content;
header = new RawSource(headerStr);
}

if (startsWithAtRuleImport) {
if (typeof header !== "undefined") {
externalsSource.add(header);
}

// HACK for IE
// http://stackoverflow.com/a/14676665/1458162
if (module.media) {
Expand All @@ -1013,6 +1019,10 @@ class MiniCssExtractPlugin {
externalsSource.add(content);
externalsSource.add("\n");
} else {
if (typeof header !== "undefined") {
source.add(header);
}

if (module.media) {
source.add(`@media ${module.media} {\n`);
}
Expand Down
23 changes: 23 additions & 0 deletions test/cases/pathinfo-devtool-source-map/expected/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/cases/pathinfo-devtool-source-map/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: yellow;
}
3 changes: 3 additions & 0 deletions test/cases/pathinfo-devtool-source-map/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "./style.css";
import "./other.css";
import "./extra.css";
3 changes: 3 additions & 0 deletions test/cases/pathinfo-devtool-source-map/other.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: blue;
}
3 changes: 3 additions & 0 deletions test/cases/pathinfo-devtool-source-map/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: red;
}
22 changes: 22 additions & 0 deletions test/cases/pathinfo-devtool-source-map/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Self from "../../../src";

module.exports = {
entry: "./index.js",
devtool: "source-map",
output: {
pathinfo: true,
},
module: {
rules: [
{
test: /\.css$/,
use: [Self.loader, "css-loader"],
},
],
},
plugins: [
new Self({
filename: "[name].css",
}),
],
};