You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I work on a project that uses the css function from @emotion/css for almost all styles. We also use the stylis-rtl-plugin to transform styles to RTL ones.
(One issue with our approach is that it only works for calls to @emotion/css which are lazy-loaded instead of the initial chunk which is not something I have a solution for)
We recently started splitting up our app with module federation which has led to difficulties managing the emotion instance, which needs to be shared between all micro frontends, but this shared module configuration conflicts with our existing webpack alias.
Proposed solution
If emotion allowed overriding the default instance, we would not have to do this webpack alias solution and could instead call an overrideEmotion function to set new values to css and other functions.
I wrote a patch on our repo to add this feature, and it works:
The problem
I work on a project that uses the
css
function from@emotion/css
for almost all styles. We also use thestylis-rtl-plugin
to transform styles to RTL ones.We call the
generateEmotion
function from our localization script which also sets the document.dir variable.To make this work with have an alias defined in our webpack config to make it so all
@emotion/css
imports point at this file:(One issue with our approach is that it only works for calls to @emotion/css which are lazy-loaded instead of the initial chunk which is not something I have a solution for)
We recently started splitting up our app with module federation which has led to difficulties managing the emotion instance, which needs to be shared between all micro frontends, but this shared module configuration conflicts with our existing webpack alias.
Proposed solution
If emotion allowed overriding the default instance, we would not have to do this webpack alias solution and could instead call an
overrideEmotion
function to set new values tocss
and other functions.I wrote a patch on our repo to add this feature, and it works:
Then the
generateEmotion
function above can be updated to this:This makes it so all calls to
css
use the stylis plugin and whatever other overrides you might want.Alternative solutions
Is it possible to directly mutate the emotion cache to set new values?
Additional context
The text was updated successfully, but these errors were encountered: