Fix asset path issue for "compound-design-tokens" package #26646
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The fix given here #26069 does not work if one clone the
compound-design-tokens
package separately and link it within thematrix-react-sdk
, because the regex/@vector-im(?:\\|\/)compound-(.*?)(?:\\|\/)/
does not match the paths in case of a cloned & linked package due to the missing substring@vector-im
, see below:Resource paths (on Windows) are e.g. ...
Not linked package
resourcePath: C:\src\matrix-react-sdk\node_modules\@vector-im\compound-design-tokens\icons\chat-solid.svg
Cloned & linked package
resourcePath: C:\src\compound-design-tokens\icons\chat-solid.svg
Problem:
The main problem is not whether absolute vs relative paths but that the
compound-design-tokens
package does not have adist
orres
subfolder to serve the assets so that the existing regex/^.*[/\\](dist|res)[/\\]/
does not match.Solution:
The solution is to add the missing root folder name for the assets to the above regex, with ...
/^.*[/\](dist|res|compound-design-tokens)[/\]/
I have tested this for both scenarios (linked/not linked) on Windows and it works with the regex statement:
const prefix = /^.*[/\\](dist|res|compound-design-tokens)[/\\]/;
The full part regarding
compoundImportsPrefix
is in this case obsolete and can be removed in thewebpack.config.js
.Signed-off-by: menturion [email protected]
This change is marked as an internal change (Task), so will not be included in the changelog.