Replies: 2 comments 2 replies
-
What's your use-case for this approach? Since Vanilla Extract generates your CSS at build-time, the only thing you're dynamically importing here is a class name, literally just a string. This won't end up reducing your CSS bundle at all, if that's what you're trying to achieve. |
Beta Was this translation helpful? Give feedback.
-
Currently using nextjs 13 App Router and dynamically importing my theme file like this in the layout: // set your import name to any derived value you need to identify
const styleFile = tenantName;
// dynamically import into your file.
const { themeClass }: { themeClass: string } = await import(
`@/theme/themes/${styleFile}.css`
); This of course only works for server rendering, and maybe static export- not in the browser. Since it's just a single top level layout, this seems reasonable to me, but may not meet your requirements. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
theme/index.css.ts
theme/themes/light.css.ts
theme/themes/dark.css.ts
pages/index.tsx
Beta Was this translation helpful? Give feedback.
All reactions