Problem/Motivation
SDC lets you alter the auto-generated Drupal library using libraryOverrides in the component definition file. It will then treat the paths for CSS and JS as relative to the component library folder, so it can be found later on. This process does not check if the provided URL is external or not. This leads to broken URLs in the front-end.
Temporary workaround
Manually define a library that contains this external JS/CSS, and add a dependency to it in your component instead.
Steps to reproduce
Add the following to your component definition:
libraryOverrides:
js:
https://drupal.org/fake-dependency/index.min.js: { }
css:
component:
https://drupal.org/fake-dependency/styles.css: { }
Then render the component normally.
You will observe that the browser is trying to request: https://d10.ddev.site/en/admin/config/modules/contrib/cl_devel/components/component-details/https://drupal.org/fake-dependency/index.min.js

Proposed resolution
The code that builds the path relative to the component directory should check if the path is external or not, in both CSS and JS.
Remaining tasks
- Write the fix.
- Add an automated test for the fix.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3357382
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3357382-unable-to-override
changes, plain diff MR !4182
Comments
Comment #2
e0ipsoComment #4
e0ipsoComment #7
robert ngoI tried a fix using `UrlHelper::isExternal()` to detect external JS.
Also, should we have a mirror issue for external CSS?
Comment #8
robert ngoComment #9
smustgrave commentedTested using #3365497: Create new SDC component for Umami Banner and confirmed the issue by adding
Applying the MR I get Uncaught ReferenceError: exports is not defined
Which I think is unrelated so the error from this ticket appears to have been resolved.
Comment #10
e0ipsoI updated the IS to reflect that we also need this for CSS. Thanks @Robert Ngo for pointing it out in #7.
Comment #11
robert ngoI've revised the fake-dependency URLs and added the case for external CSS.
It's ready to retest now.
Comment #12
robert ngoComment #13
smustgrave commentedSame test from #9 but using css option too.
Confirmed the bug and the MR fixed the console error.
Comment #16
lauriiiCommitted 575c533 and pushed to 11.x. Thanks! Also cherry-picked to 10.1.x.