From 332cd5a67f9e011177cf2ac7883fbb1d9300526e Mon Sep 17 00:00:00 2001 From: Germain Date: Fri, 18 Aug 2023 09:23:37 +0100 Subject: [PATCH] Allow external assets loading --- webpack.config.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 198be2059a7..92557711d41 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -725,14 +725,20 @@ module.exports = (env, argv) => { * @return {string} The returned paths will look like `img/warning.1234567.svg`. */ function getAssetOutputPath(url, resourcePath) { + const isKaTeX = resourcePath.includes("KaTeX"); // `res` is the parent dir for our own assets in various layers // `dist` is the parent dir for KaTeX assets const prefix = /^.*[/\\](dist|res)[/\\]/; - if (!resourcePath.match(prefix)) { + /** + * Only needed for https://github.com/vector-im/element-web/pull/15939 + * If keeping this, we are not able to load external assets such as SVG + * images coming from @vector-im/compound-web. + */ + if (isKaTeX && !resourcePath.match(prefix)) { throw new Error(`Unexpected asset path: ${resourcePath}`); } let outputDir = path.dirname(resourcePath).replace(prefix, ""); - if (resourcePath.includes("KaTeX")) { + if (isKaTeX) { // Add a clearly named directory segment, rather than leaving the KaTeX // assets loose in each asset type directory. outputDir = path.join(outputDir, "KaTeX");