-
Notifications
You must be signed in to change notification settings - Fork 51
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
Keep directory structure / folder hierarchy when copying with recursive glob #32
Comments
@mario-d-s hey, won't this work for your case? copy({
targets: [
{ src: 'assets/**', dest: 'dist/assets' },
]
}) It will copy the contents of |
Hi @vladshcherbin thank you for your quick comment! However this does not work as expected. Also the use case of filtering input is not supported like this:
This will place all |
@mario-d-s hm, that's interesting. If I use this code: // folder structure
// assets/js
// assets/js/inside-one.js
// assets/one.js
// assets/two.js
copy({
targets: [
{ src: 'assets/**', dest: 'dist/assets' },
]
}) The output for me will be // dist/assets/js
// dist/assets/js/inside-one.js
// dist/assets/one.js
// dist/assets/two.js So for me it just copies all directories and their contents and keeps same hierarchy but doesn't flatten them. Interesting if it works differently for you. The I'll think about this one, thank you the suggestion :) |
@vladshcherbin I'm willing to help you by debugging our case where it strangely goes wrong, and also open a pull request for implementing the filtering use case, when I get some time (might not be soon though, don't take this as a commitment 😄) |
|
@mario-d-s actually, I was able to reproduce it too. So no need for any debug info, will be investigating the issue :) |
@mario-d-s ok, so this was my misunderstanding how globstar (**) works alone. For the first example (directory and keep structure) try this one instead: copy({
targets: [
{ src: 'assets/*', dest: 'dist/assets' },
]
}) Does it work correctly now? |
@vladshcherbin yes, using that syntax it does work, but that is not correct - it would be confusing to people who explicitly want to copy only first-level files as that is what such glob would normally do. I do think it would be better to fix this so that |
@mario-d-s that's the correct way how glob works thought. If you want to copy only files, you have different options:
There is also an option to turn off globstar (**) so it works as wildcard (*): { src: 'assets/**', dest: 'dist/assets', globstar: false } As per |
@vladshcherbin this is not how globs work in other node projects nor in In the meantime I found a "competing" (for lack of a better word) plugin to yours that does it right: The possible way is that you recreate whatever
And you have this target for your plugin:
In
If you put it like this:
You should get:
|
@mario-d-s when I wrote about how glob works I meant how globstar works alone, for example A simple wildcard glob solution from this comment also works correctly and will copy first level files and folders. So how glob works in this package is the same as other node packages and bash. I understand what you mean with So this feature can be added either by adding such parent resolution function or by using another copy function (for example cpy you've mentioned). In your project, do you actually need to copy files with something like |
Hi @vladshcherbin, we do indeed need this function. |
To weigh in on this issue, we're using this plugin to move non-js assets across with a typescript class library we are building. It's not doing what we expect w/ the following config:
With the follwing src structure:
We expect the following output:
But we get:
|
@mario-d-s @vladshcherbin I did a few changes for preserving the parent directories, I can send the pull request with that if you can, what I did? when u get the src -> ./src/**/*.html replace the base src for dest we get: ./dist/components/mycomponent.html I did a couple of tests and works fine |
@vladshcherbin any updates? |
Released in 3.2.0 🎉 Please test in your projects to see if it's working as expected. |
this fixed the problem for us, thanks for fixing |
Thanks for this fix! I noticed though that the option is missing at https://github.com/vladshcherbin/rollup-plugin-copy/blob/master/index.d.ts#L22 |
@dasa nice catch, thanks. Fixed in 3.2.1 |
Glob is still/again broken in v3.3.0. Please revisit. Souce files:
Settings: Output is
Currently it copies the files into the dest-dir too. |
Same problem here! Exactly the same configuration as @rottmann |
While waiting you can write it yourself. I went with this approach.
|
Thank you @Ballpin. This satisfies the needs of my current project, but I'm leaving a note for future devs that switching to https://github.com/paulmelnikow/rollup-plugin-cpy may be neccessary. |
When using the plugin like this:
It would be nice to optionally copy the directory structure as-is.
My suggestion: support a
flatten
option for atarget
that defaults totrue
for keeping backwards compatibility.The text was updated successfully, but these errors were encountered: