Ad

Shopify Use Subdirectory In Asset Folder

- 1 answer

Instead of putting all files in a place in the asset folder, I want to use CSS files in CSS folder, JS files in js folder and images in images folder. Then Include them in the asset folder, so that I can maintain the files easily.

I know Shopify doesn't support any sub-directories within the asset folder. But is there any trick to do that?

Ad

Answer

According to a Shopify employee. This is currently not possible and the reason is due to a limitation of the CDN they use. See that post here.

Regardless, it's not good practice to have source files in the assets folder. Look into the Shopify Slate tool. It's a theme scaffold and command line interface that helps keep your project structure organized.

You can organize your assets (both CSS and JavaScript) as source files with directory structures in a manner similar to this:

styles/
  global/
  modules/
  settings
  tools/
  vendor/

The command line tool takes care of compiling all the source files into one CSS/JS file! As a consequence, you don't need to worry about including the respective files with <link> or <script> tags because it's all taken care of already!

Ad
source: stackoverflow.com
Ad