5

How do I set the priority of css files so when it optimized all css files, custom css file gets higher priority?

3

Files get concatenated in an order taken from Sitecore tree and then minified, so you can control it using standard sort order field.

I am not sure if an order will help you in any way.

The standard approach to creating custom class is to either define more specific CSS selector or use !important or overwrite standard class.

Unfortunately, it is impossible to overwrite CSS classes right now. So if you have a CSS file in a base theme you cannot simply overwrite its content in your current theme, you have to use techniques listed above.

3

In case if you are using SXA AssetService pipeline to programmatically include the whole theme, then there is an SortOrder property which you can use:

public class AddCustomTheme: AddAssetsProcessor
{
    public override void Process(AssetsArgs args)
    {
        Item theme = ...;

        args.AssetsList.Add(new ThemeInclude
        {
            SortOrder = 0,
            Name = theme.Name,
            ThemeId = theme.ID,
            Theme = theme
        });
    }
}
  • That could be helpful only for JS files, CSS files can be loaded in random order. – Alan Płócieniak Jan 25 '18 at 8:08
1

To get the priority your files should be at the very last.

This is so basic, The files are optimized in the sort order of the files in the folder, just place your custom.css at the very last in the folder.

You can do it by using the top options from the Home Nav.

enter image description here

Same goes for your Javascript files, you should make sure that your custom.js file which initializes the JS options, should be at the very last.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.