Tutor MFE custom theme/styling help

Hi, I know topics about MFE have been brought up many times before, but I am just going to start a new post because most of them are already closed.

I am trying to customize the theme on my MFE plugins by adding my own logo and changing some styles from a remote repository, but I haven’t been able to get my changes to work.

I have been trying to follow the instructions from

And a few threads on similar issues:

Here’s what I did:

Creating a new plugin and adding a patch:

  1. Created a new plugin with this patch:
from tutor import hooks

hooks.Filters.ENV_PATCHES.add_item(
    (
        "mfe-dockerfile-post-npm-install",
        """
RUN npm install '@edx/brand@git+<my remote repository>'
"""
    )
)
  1. Push changes to remote repository
  2. Making sure that I have my plugin listed and enabled
tutor plugins enable <myplugin>
  1. Check tutor root config.yml to make sure the new plugin is included.
  2. Check tutor plugins list to make sure the new plugin has the version pointing to my local directory where the new plugin .py file is.

Setting up tutor-indigo

I think these npm install commands are overwriting my custom new plugin patch based on what I found in my docker build logs when I’m rebuilding the mfe images. They ran after my npm install openedx/brand-openedx

RUN npm install '@edx/brand@npm:@edly-io/indigo-brand-openedx@^2.1.1'
RUN npm install '@edx/frontend-component-header@npm:@edly-io/indigo-frontend-component-header@^3.1.3'
RUN npm install @edly-io/indigo-frontend-component-footer@^2.0.0

Here’s what I did:

  1. Fork and clone from overhangio/tutor-indigo
  2. Remove the entire mfe patch from tutorindigo/plugin.py
  3. Run tutor mounts add <path to local tutor-indigo>*
  4. Run tutor config save

Setting up openedx/brand-openedx

  1. Fork and clone from openedx/brand-openedx
  2. Replace the logos with my own, and making sure the names stay the same.
  3. Modify _overrides.scss:
#root .learner-variant-header {
    background-color: #9e1b34;
}
  1. Run tutor config save
  2. Run tutor images build --no-cache --no-registry mfe (Pain in the ass building with just single CPU otherwise it would fail)
  3. Check my docker build logs, and it did run npm install '@edx/brand@git+<my remote repository>,', and the mfe patches I removed from tutor-indigo are not in the logs.
  4. Run tutor local launch

However, my local instance still shows the default indigo theme and logos. Am I missing something? I’m running tutor v18.1.3

Hi @Tidbit0519, welcome to the forum!!

Many things can happen, but I point out two to start:

  • You do not tutor mounts add tutor plugins. You just pip install them and tutor plugins enable.
  • Mounting makes sense only in dev, not in local.

Branding Open edX is always a tricky task. Check out our branding plugin, which may help you with most of these tasks, or may inspire your own plugin.

Hope it helps!

Thanks for the reply @Andres.Aulasneo! Does it support the latest release of tutor redwood 18.1.3? I tried installing and enabling plugin and I ran into this error:

Error applying filter: func=<function _add_my_mfe at 0x106d11da0> contexts=['plugins', 'app:branding']'

Error rendering patch 'openedx-cms-development-settings':

# MFE-specific settings

{% if get_mfe("course-authoring") %}

COURSE_AUTHORING_MICROFRONTEND_URL = "http://{{ MFE_HOST }}:{{ get_mfe('course-authoring')["port"] }}/course-authoring"

CORS_ORIGIN_WHITELIST.append("http://{{ MFE_HOST }}:{{ get_mfe('course-authoring')["port"] }}")

LOGIN_REDIRECT_WHITELIST.append("{{ MFE_HOST }}:{{ get_mfe('course-authoring')["port"] }}")

CSRF_TRUSTED_ORIGINS.append("http://{{ MFE_HOST }}:{{ get_mfe('course-authoring')["port"] }}")

{% endif %}

Error rendering template apps/openedx/settings/cms/development.py

Error: Project root does not exist. Make sure to generate the initial configuration with `tutor config save --interactive` or `tutor local launch` prior to running other commands.

And it wouldn’t even let me run tutor plugins list or tutor local launch (it went back to normal after I pip uninstall it again):

Error applying filter: func=<function _add_my_mfe at 0x1040b6700> contexts=['plugins', 'app:branding']'
Error applying action: func=<function _mounted_mfe_image_management at 0x1040f04a0> contexts=['plugins', 'app:mfe']'
Error applying action: func=<function _enable_plugins at 0x1037da160> contexts=[]'
Error: Project root does not exist. Make sure to generate the initial configuration with `tutor config save --interactive` or `tutor local launch` prior to running other commands.

I’m using tutor-contrib-branding v18.6.0

I am getting the same error.

Hi @Tidbit0519 ,

I really appreciate the steps you’ve taken so far! Let me explain things in a bit more detail—I hope this will be helpful.

  • Changing Logos:
    You can replace your logo by placing it at this path:
    tutorindigo/templates/indigo/lms/static/images.
    Here’s an article that explains what you can customize with Tutor Indigo: Logos and Images Alterations.
  • Installing the Plugin:
    You can install a custom theme with the following command:
pip install custom-theme

Regarding styling, there are two parts you need to know:

  1. LMS Legacy Pages: These are styled through Tutor Indigo. Here’s more about adjusting styles: Sass Styles Adjustments.
  2. MFEs (Micro-Frontend): The MFEs use the edx-brand package for styling. You can install it like this:
RUN npm install '@edx/brand@npm:@edly-io/indigo-brand-openedx@^2.1.1
  1. If you want to install your own brand package, replace this line in Tutor Indigo:
npm install indigo-brand-openedx

with your custom package installation.

I’m not entirely sure if you’re referring to style changes in the MFEs or the LMS legacy pages. Could you please clarify? That way, I can assist you better!

1 Like

Thanks @hinakhadim for the explanation! I was just trying to change the MFE pages.

  1. Replaced the learner dashboard MFE patch with this un tutor-indigo’s plugin.py:
"mfe-dockerfile-post-npm-install-learner-dashboard",
            """
RUN npm install '@edx/brand@git+https://github.com/<github username>/brand-openedx.git'{% if INDIGO_ENABLE_DARK_THEME %} --theme=dark{% endif %}
RUN npm install '@edx/frontend-component-header@npm:@edly-io/indigo-frontend-component-header@~3.0.0'
RUN npm install @edly-io/indigo-frontend-component-footer@^2.0.0

COPY indigo/env.config.jsx /openedx/app/
"""
  1. Replaced the logo and favicon at this path: tutorindigo/templates/indigo/lms/static/images with my custom logos, and ran pip install <mycustomtheme>.
  2. Ran tutor config save, and rebuild openedx and mfe image.

I was able to see my custom logo, but favicon is still using indigo’s.

Also, is there a better way to rebuild MFE image? It takes too long and it would sometimes fail unexpectedly even with max parallelism set to 1.

Great to know that!

  1. For favicon, make sure you added a file with name favicon.ico in tutorindigo/templates/indigo/lms/static/images folder. Install the theme updated version and run tutor config save. Then rebuild openedx image.
  2. There’s no way better to build mfe images other than max parallelism set to 1 in my opinion.

In Redwood, the learner-dashboard mfe used its header component instead of the @edx/frontend-component-header package. In Sumac, I’m expecting the header package for the learner dashboard, and styling issues for the dashboard header will be gone.

1 Like

Sorry, let me clarify. My favicon.ico did update for the LMS Legacy Pages, but whenever I switch over to MFE pages, the favicon will revert to indigo’s.

The tutor-mfe repo explained a way to change the logos and favicon for the MFE pages here, Customising MFEs.

(
            "mfe-lms-common-settings",
            """
    MFE_CONFIG["LOGO_URL"] = "<URL>/logo.svg"
    MFE_CONFIG["FAVICON_URL"] = "<URL>/favicon.ico"
    """
        ),

What exactly do I put in the <URL>? Would a GitHub link to the image work? Or do I need a CDN setup somewhere?

Or, I was thinking of just forking and cloning the MFE repos, and adding the favicon there.

I’m expecting some cache issue on mfe sites if favicon isn’t updating. Otherwise to change the favicon, you can use this URL.

MFE_CONFIG["LOGO_URL"] = LMS_ROOT_URL + "/theming/asset/images/logo.png"

I added this patch to the plugin.py in tutorindigo.

"mfe-lms-common-settings",
            """
MFE_CONFIG["FAVICON_URL"] = LMS_ROOT_URL+"/theming/asset/images/favicon.ico"
MFE_CONFIG["LOGO_URL"] = LMS_ROOT_URL+"/theming/asset/images/logo.png"
"""

Tried tutor images build --no-cache --no-registry-cache mfe too, and it works now! Thank you!