vladshcherbin / rollup-plugin-copy

Copy files and folders using Rollup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wildcard support

r4fx opened this issue · comments

Hi! thank you for nice plugin,
is there any plan to support wildcards to achieve something like below?

 { files: './docs/!*.html', dest: './docs/dist' },
 { files: './docs/robots.txt', dest: './docs/dist' },
 { files: './docs/assets/favicon/!*.*', dest: './docs/dist' },
 { files: './docs/assets/images', dest: './docs/dist/assets/images' },
 { files: './docs/assets/styles', dest: './docs/dist/assets/styles' },

Hey,

Yes, I have plans to add glob paths support some time later. Need to test them well too so they don't produce weird results.

Here you have it using the glob library that uses 16.1k gzipped:

import glob from 'glob';
const pluginsList = [
    copy({
      targets: [...glob.sync('public/**/*')],
    })
]

Then you just need to add it to your config and export it

It's probably better to leave this to a third-party lib as @AnthonySLWhite suggests, and just write it as a FAQ in the README, or something with an example or two. Much easier to maintain, much more versatile and configurable, and equally easy to use.

Just a small update about this one:

When writing v1, I actually tried to use cpy package to copy files which has glob support, but it had some problems I didn't remember. I tried it today and found this problems again (mostly related to creating folders, some mentioned in cpy package issues).

I'll try to just use plain glob, until then try solution from @AnthonySLWhite. If I won't be able to solve this, I'll add a recipe with this solution to readme as @lazarljubenovic suggested.

Thanks to everyone :)

@vladshcherbin can you release please? We need glob. Thanks.

Released in 3.0.0 🎉

Thanks to everyone for patience and support. Took a bit longer than I'd expect, but I'm happy I took time to think about api and I'm happy how it turned out.