ohildn's avatar

Keeping folder-structure when copying with laravel mix

Hey,

I am currently copying all SVG-Files from one folder to another using this command:

mix.copy('resources/images/**/*.svg', 'public/images');

This way files from subdirectories are only copield to the root-directory and not in the folder they have been before.

Is there a way to keep the Folder-Structure while still copying only SVGs?

Oliver

0 likes
2 replies
Braunson's avatar

Hmm... https://laravel-mix.com/docs/6.0/copying-files

Please note that, when providing a directory path as the first argument, the output will retain the original directory structure. If you wish to "flatten" it, provide a wildcard search.

So you want to remove the wildcard ** it seems and individually specify each folder for example:

mix.copy([
    'resource/images/foobar/*.svg',
    'resource/images/laracasts/*.svg'
], 'public/images');

I'm not 100% if this will work, if not this could be a feature request in the Laravel Mix repo https://github.com/laravel-mix/laravel-mix

ohildn's avatar

Thank you for your answer.

Unfortunately this is not really a solution for me as I don't know about the folder-structure.

I also tried something like mix.copy('resources/images/**/*.svg', 'public/images/**'); and a lot of other variants but I never got it to work.

Not sure if it is even possible.

Please or to participate in this conversation.