Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding subfolder structure to snippets #115

Open
efekurnaz opened this issue Sep 8, 2020 · 1 comment
Open

Adding subfolder structure to snippets #115

efekurnaz opened this issue Sep 8, 2020 · 1 comment

Comments

@efekurnaz
Copy link

efekurnaz commented Sep 8, 2020

Hey all!

I use a lot of snippets and it's getting harder to organize. I'm trying to add a folder structure to snippets folder but couldn't output the files into snippets/ root. Any ideas how can I do it?

Example:
from /snippets/components/foo.liquid
to /snippets/foo.liquid

I have installed https://webpack.js.org/plugins/copy-webpack-plugin/

Added this code below to my slate.config.js, no errors, nothing happens. Still builds the folders as it is.

const CopyPlugin = require('copy-webpack-plugin');

...
plugins: [
    new CopyPlugin({
      patterns: [
        { 
          from: 'src/snippets/**/*',
          to: 'build/snippets/' }
      ],
    }),
  ]
...
@davidwarrington
Copy link

This is more a restriction of Shopify than Slater. You should be able to sort it with the code you're already using though.

I wrote this whilst playing around with the idea last year, and assuming the plugin hasn't changed too much, I'd imagine it will still work.
https://github.com/davidwarrington/filepath-flattener/blob/master/webpack.config.js

Your render tag needs to reference the path in some way. For example, if I had a snippet in snippets/product/card.liquid, I'd include it as {% render 'product.card' %}

As you can see, the delimiter I chose was ., but you might want to choose something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants