File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -733,6 +733,7 @@ function getAssetOutputPath(url, resourcePath) {
733
733
// `res` is the parent dir for our own assets in various layers
734
734
// `dist` is the parent dir for KaTeX assets
735
735
const prefix = / ^ .* [ / \\ ] ( d i s t | r e s ) [ / \\ ] / ;
736
+
736
737
/**
737
738
* Only needed for https://github.com/vector-im/element-web/pull/15939
738
739
* If keeping this, we are not able to load external assets such as SVG
@@ -742,6 +743,21 @@ function getAssetOutputPath(url, resourcePath) {
742
743
throw new Error ( `Unexpected asset path: ${ resourcePath } ` ) ;
743
744
}
744
745
let outputDir = path . dirname ( resourcePath ) . replace ( prefix , "" ) ;
746
+
747
+ /**
748
+ * Imports from Compound are "absolute", we need to strip out the prefix
749
+ * coming before the npm package name.
750
+ *
751
+ * This logic is scoped to compound packages for now as they are the only
752
+ * package that imports external assets. This might need to be made more
753
+ * generic in the future
754
+ */
755
+ const compoundImportsPrefix = / @ v e c t o r - i m (?: \\ | \/ ) c o m p o u n d - ( .* ?) (?: \\ | \/ ) / ;
756
+ const compoundMatch = outputDir . match ( compoundImportsPrefix ) ;
757
+ if ( compoundMatch ) {
758
+ outputDir = outputDir . substring ( compoundMatch . index + compoundMatch [ 0 ] . length ) ;
759
+ }
760
+
745
761
if ( isKaTeX ) {
746
762
// Add a clearly named directory segment, rather than leaving the KaTeX
747
763
// assets loose in each asset type directory.
You can’t perform that action at this time.
0 commit comments