Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 3e548cc

Browse files
committed
fix(Quantum): Quantum CSS splitting loads sourcemaps on production
1 parent 89800ef commit 3e548cc

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/core/File.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,11 @@ export class File {
637637
const newName = joinFuseBoxPath("/", this.context.inlineCSSPath, `${fastHash(this.info.fuseBoxPath)}.map`);
638638
this.contents = this.contents.replace(re, `$1${newName}$3`);
639639
this.context.output.writeToOutputFolder(newName, this.sourceMap);
640+
640641
if (this.context.fuse && this.context.fuse.producer) {
641642
const producer = this.context.fuse.producer;
642-
producer.sharedSourceMaps.set(this.info.fuseBoxPath, this.sourceMap);
643+
const fullName = `${this.collection.name || "default"}/${this.info.fuseBoxPath}`;
644+
producer.sharedSourceMaps.set(fullName, this.sourceMap);
643645
}
644646
}
645647

src/quantum/core/CSSCollection.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CSSFile } from "./CSSFile";
22
import { QuantumCore } from "../plugin/QuantumCore";
3-
import { Concat } from "../../Utils";
3+
import { Concat, joinFuseBoxPath } from "../../Utils";
44
import { QuantumBit } from "../plugin/QuantumBit";
55

66
export class CSSCollection {
@@ -10,6 +10,7 @@ export class CSSCollection {
1010
public quantumBit: QuantumBit;
1111
private renderedString: string;
1212
private renderedFileName: string;
13+
public sourceMapsPath: string;
1314
public splitCSS: boolean;
1415
constructor(public core: QuantumCore) {}
1516

@@ -34,7 +35,8 @@ export class CSSCollection {
3435
}
3536
});
3637
if (this.useSourceMaps) {
37-
concat.add(null, `/*# sourceMappingURL=/${this.renderedFileName}.map */`);
38+
this.sourceMapsPath = joinFuseBoxPath("/", `${this.renderedFileName}.map`);
39+
concat.add(null, `/*# sourceMappingURL=${this.sourceMapsPath} */`);
3840
}
3941
this.sourceMap = concat.sourceMap;
4042
this.renderedString = concat.content.toString();
@@ -47,7 +49,7 @@ export class CSSCollection {
4749

4850
public setString(str: string) {
4951
if (this.useSourceMaps) {
50-
str += "\n/*# sourceMappingURL=/" + this.renderedFileName + ".map */";
52+
str += "\n/*# sourceMappingURL=" + this.sourceMapsPath + " */";
5153
}
5254
this.renderedString = str;
5355
return str;

src/quantum/plugin/BundleWriter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ export class BundleWriter {
190190
if (!cssCollection.splitCSS) {
191191
this.core.producer.injectedCSSFiles.add(cssResultData.filename);
192192
}
193+
193194
if (useSourceMaps) {
194-
output.writeToOutputFolder(this.core.opts.getCSSSourceMapsPath(), cssCollection.sourceMap);
195+
output.writeToOutputFolder(cssCollection.sourceMapsPath, cssCollection.sourceMap);
195196
}
196197
}
197198
};

0 commit comments

Comments
 (0)