Skip to content

Commit

Permalink
Add ability to use custom CSS files for customization
Browse files Browse the repository at this point in the history
  • Loading branch information
louisescher committed Jan 15, 2025
1 parent abaf1a7 commit 2ffd4b1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/studiocms_ui/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function integration(options: Options = {}): AstroIntegration {
hooks: {
'astro:config:setup': (params) => {
const { injectScript, updateConfig } = params;
const { resolve: rootResolve } = createResolver(params.config.root.pathname);

updateConfig({
vite: {
Expand All @@ -57,6 +58,22 @@ export default function integration(options: Options = {}): AstroIntegration {
});

injectScript('page-ssr', `import 'studiocms:ui/global-css';`);

if (options.customCss) {
const customCss = viteVirtualModulePluginBuilder(
'studiocms:ui/custom-css',
'sui-custom-css',
`import '${rootResolve(options.customCss)}'`
);

updateConfig({
vite: {
plugins: [customCss()]
}
});

injectScript('page-ssr', `import 'studiocms:ui/custom-css';`);
}
},
},
};
Expand Down

0 comments on commit 2ffd4b1

Please sign in to comment.