Open marcoveeneman opened 3 years ago
I managed to figure out what went wrong. Going to answer my own question here in case anyone will face the same issue.
It turns out the parentAliases.js
file from the frontend-builder
package is making assumptions about the name of the parent theme.
The parent theme is matched using the following regex: /<parent>[a-z]+\/[^\-]+\-([a-z]+)<\/parent>/i
, in other words, it matches theme-creativeshop
as well as my-child
, but not my-child-child
, it is assumed a theme will have only one dash in the name.
Then when a match has been found in parentAliases.js, the parentPath is resolved using path.resolve('../theme-${parentName}');
, constructing the path to the parent theme. Here the assumption is made a theme is always starting with theme
, which was not the case for me, i used my-child
, resulting in a parentPath of ../theme-child
instead of ../my-child
.
A theme must be named so that it will match the following regex: /creativestyle\/theme-([a-z]+)/i
or it will not work.
This will work: ✅ creativestyle/theme-customchild ✅ creativestyle/theme-customgrandchild
This will not work: ❌ anotherstyle/theme-creativeshop ❌ creativestyle/theme-custom-child ❌ creativestyle/custom-child
I'm not sure if current behaviour is expected, feel free to close this issue if it is.
It would be nice to add support for anothercompany/theme-whatever This would make the biggest benefit.
When we create a child theme now for a customer we name it cust creativestyle/theme-customer. Theme to clearly show it is a theme. And then no dashes. This is by design. But the fact that the namespace needs to be creativestyle is there just because we never had a need to use another one.
It would be nice if somebody adds this support.
I checked our projects, we we see that we have themes like creativestyle/theme-customer-b2b and that works.
I am not sure why -child is not working for you.
Thanks for checking. The creativestyle/theme-customer-b2b
theme itself will work fine. However, when creating a child of creativestyle/theme-customer-b2b
, like creativestyle/theme-customer-b2b-child
, it will not work because the parent it will search for is creativestyle/theme-customer
. At least that is what i am seeing 🤔
It would be nice to add support for anothercompany/theme-whatever This would make the biggest benefit.
When we create a child theme now for a customer we name it cust creativestyle/theme-customer. Theme to clearly show it is a theme. And then no dashes. This is by design. But the fact that the namespace needs to be creativestyle is there just because we never had a need to use another one.
It would be nice if somebody adds this support.
I added support for this in a PR in the frontend-builder repo. Would be great if it gets accepted 😄
Thank you for your contribution.
We will check your implementation internally and in case everything will be fine, we will merge it.
Hi,
I'm currently doing some experiments with theme-creativeshop. I created a child theme which is working perfectly! I extended the child theme and would like to create another child based on the child, resulting in the following inheritance structure:
I generated a new child using
mtg
according to the guide and changed the following line ingrandchild/src/theme.xml
:to
However, when building the grandchild i encounter the following error in
yarn build
:Reverting the parent to theme-creativeshop the theme builds again (making it child instead of grandchild). I now start to wonder if this scenario is supported or not (yet?) hence i opened this ticket. Can i create a grandchild of theme-creativeshop? Am i doing something wrong?