App: load CSS file from the assets folder

App: load CSS file from the assets folder

YvanHK
Shopify Partner
13 1 1

I'm creating an app (app-embed.liquid) where I want to have the CSS 'styles.css' in another folder:

Screenshot 2023-02-06 at 7.50.34 PM.png

 

From what I can read, we can achieve so for conditional app blocks but not sure it is working for my case:

Screenshot 2023-02-06 at 7.51.41 PM.png

I added the <link> above and the schema tag.

{% schema %}
  {
    "name": "",
    "target": "head",
    "stylesheet": "styles.css",
    "settings": []
  }
{% endschema %}

 

Do I need to have all CSS, assets, JS and liquid in one file or I can split?

Thanks for your help.

 

Reply 1 (1)

siddhesh2106
Shopify Partner
7 0 0

I was also trying to upload a stylesheet from my app embed block, code is given below


{% schema %}
{
"name": "App Embed",
"target": "head",
"settings": [],
"stylesheet": "app-embed.css",
"javascript": "app-embed.js"
}
{% endschema %}
I saw that the app-embed.css file was getting loaded in the developer console but the styles were not getting applied to the divs which I had injected in the store. I could not find out why but I found an alternate approach of injecting the styles from the js file itself and it worked. Not sure if this is something I should continue or try to fix the css styles getting applied. Can anyone help?