Comprehension of BASE_URL usage for CSS #269
Unanswered
quentin-desbin
asked this question in
Q&A
Replies: 2 comments 7 replies
-
(Totally related to #21 I think) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Why do you think it is bad practice? Just set the base and the URL's will work. What I see as being potentially bad practice is separating the bundled JS from the produced CSS. Why do you do this? Are you bundling, then copying the JS files to one place and then the CSS to another place? Why all this? |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
(Coming back from a long time)
I have a question concerning the CSS algorithm and the usage of
import.meta.env.BASE_URL
but maybe it's due to my incomprehension of something.Imagine that we have a root single-spa appplication (with the plugin setup as root) hosted on :
root.domain.com
If we want to have
myApp
underroot.domain.com/myApp
that loads the SSPA frommyapp.domain.com/main.js
, in this case theBASE_URL
of myApp is set-up to "" and having a CSS accessible frommyapp.domain.com/assets/cssFile.css
.Accessing to
root.domain.com/myApp
will correctly load themain.js
but the CSS algorithm when buildingmyApp
will useBASE_URL + cssFile.css
, in case of empty BASE_URL, the plugin will create a<link href="cssFile.css">
, that will finally try to loadroot.domain.com/cssFile.css
which doesn't exists.One solution is to set the
BASE_URL
ofmyApp
tomyapp.domain.com
when building for production, but I think it's not a good practice.Other solution should be to use
import.meta.url
instead ofBASE_URL
in the plugin ? (I tested by editing the source code of css-helpers.js and forcing usage of import.meta.url when building the final URL before loading the CSS and it worked)Maybe I missunderstanding something or maybe found an issue, feel free to discuss
Thanks !
Beta Was this translation helpful? Give feedback.
All reactions