Theme app extension CSS/JavaScript not working correctly on custom templates

samporiikkila
New Member
3 0 0

I started working on an app using the new theme app extensions and noticed some weird behaviour with different templates.

The documentation at https://shopify.dev/apps/online-store/theme-app-extensions/extensions-framework#:~:text=No-,template... states the following:

"The possible values are productcollectionarticle, and blog."

However, using other templates such as index or page seems to work and Shopify CLI also gives this error if an incorrect template is included: 

Invalid tag 'schema': templates[0]: must be one of 404, cart, checkpoint, gift_card, list-collections, password, queue, search, customers/account, customers/activate_account, customers/addresses, customers/login, customers/order, customers/register, customers/reset_password, article, blog, collection, page, product, index

The real problem however, is that when I create a new custom template, no CSS or JavaScript seems to be loading at all even though the extension is presented in the add section menu. For example, I have a theme app extension block that is only available on the product template. All the CSS and JavaScript I have defined in the schema are loading correctly, but when I add the block on a custom product template, these are not loaded at all.

This only seems to be happening with blocks that have the templates attribute set. So If I exclude this attribute and allow the block to be placed on any template, the CSS and JavaScript are loading as normal.

Is there a way to get theme app extensions working on specific custom templates currently, or is this a bug?

 

0 Likes
samporiikkila
New Member
3 0 0

I got this working correctly by loading the styles and JS with link and script tags. Only loading them through the schema doesn't work correctly.

0 Likes