Bundle CSS files used in a theme

Posted by nbutler@ifslearning.ac.uk on 21-Jun-2019 09:48

Hi,

Is it possible to bundle all CSS files that are used in a theme and if so, how would I go about achieving this?  We're using version 9.1.6110.

Thanks,

Neil

All Replies

Posted by peleva on 21-Jun-2019 11:31

Hi Neil,

First of all, I would highly recommend you to start using our MVC widgets, templates and front-end packages for new Sitefinity projects, since they provide performance improvements, better control over the markup of your pages and easier management of front-end assets. Themes aren't used there anymore. (www.progress.com/.../mvc).

You can learn more about front-end resource packages for MVC here: www.progress.com/.../overview-resource-packages-mvc. In case you decide to use them, you will also be able to leverage Bootstrap out-of-the box. We offer two Bootstrap packages - for Bootstrap 3 and a new one - for Bootstrap 4. In the Bootstrap 3 package styles are minified  with grunt and in the Bootstrap 4 package this is done with node-sass through npm scripts.

In case you're using Webforms and Sitefinity Themes, you could take a look at this article: www.codeproject.com/.../Sitefinity-Bundling-and-Minification-JS-and-CSS-Fi .  Something to keep in mind is that RadStylesheetManager  combines and compresses the styles, but doesn't minify them.

Posted by nbutler@ifslearning.ac.uk on 21-Jun-2019 12:16

Hi Peleva,

Thanks for your very quick reply.  Funny you should mention that CodeProject link - I used the info there a couple of days :)  Although bundling the CSS files worked fine, the indivdual CSS files were still loaded.  Is there possibly another config setting that I need to use to prevent this from happening?

Thanks,

Neil

Posted by peleva on 21-Jun-2019 15:31

Hi again,

I believe this happens because you're referencing the css file from your them. They are loaded  by the Stylesheet manager of Sitefinity (if you've set them as a theme to your Sitefinity template through the UI), and they're loaded again from the RadStyleSheetManager on your master page.

I would suggest you to set the Theme from the UI to "no theme" (www.screencast.com/.../cTm6e66U). This way the css will be loaded only from the master page.

Posted by nbutler@ifslearning.ac.uk on 21-Jun-2019 15:37

Hi Peleva.  I thought that might be the case, but I was hoping for an quicker solution. Setting no theme breaks the whole look of the site, so I've got a bit of work to do to shift things around.

Thank you!

This thread is closed