openfun / richie

:pencil: An opensource CMS to build education portals
https://richie.education
MIT License
264 stars 85 forks source link

Issues with overriding widgets in the frontend #2447

Open sandroscosta opened 5 months ago

sandroscosta commented 5 months ago

Hello all!

We need some help overriding frontend components on our site factory and we've been encountering some challenges. We need to override widgets/SyllabusCourseRunsList/components/SyllabusCourseRun on our end, but the system is not processing the correct path. Can you point us toward the correct configuration, if it's possible to do (which I assume it is, by the documentation).

Can you gives us some additional insights? @jbpenrath

sandroscosta commented 5 months ago

Discussed with @JoaoGarcao

jbpenrath commented 5 months ago

Hi Sandro! You have to use the relative path to the correct component.

To find the proper path, you have to imagine you start from the folder of the module you are overriding within richie-education package and you want to go to the new module you created to override it.

e.g: you are in the frontend folder of a site factory and you want to override the web-analytics index module, you put the replacement module within js/web-analytics/custom.ts

js
    | web-analytics
        | custom.ts
node_modules
    | richie-education
        | js
            | web-analytics
                | index.ts

From node_modules/richie-education/js/web-analytics to go to js/web-analytics you have to do cd ../../../../../js/web-analytics

So within overrides.json you'll add :

"js/web-analytics/index.ts": "../../../../../js/web-analytics/custom.ts"

https://github.com/openfun/fun-richie-site-factory/blob/26a114bbede1bbb8a4b5d1a6ab93821823e4d468/sites/funmooc/src/frontend/overrides.json#L1-L6