Skip to content

rollup-plugin-copy: Ignore patterns, subdirectories, and false filesOnly don't mix #11

@PixievoltNo1

Description

@PixievoltNo1

I had a copy target with a src like ["WebExtension/**/*", "!**/*.{esm.js,svelte}"], and found that the negation pattern was not applying to subdirectories of WebExtension. I spent hours trying various workarounds and researching rollup-plugin-copy's dependencies to try to figure out where the problem was, eventually tracing the problem to the plugin's use of the globby option filesOnly: false. This was causing the plugin to select those subdirectories and copy their entire contents without regards to negation patterns. This strikes me as a gotcha causing needless confusion and grief for me and possibly other developers, though it can be worked around once you understand it.

My proposal for fixing this is to detect if the plugin arguments use negation patterns, globbyOptions.ignore, globbyOptions.gitignore, or globbyOptions.ignoreFiles, and have the globby options filesOnly and expandDirectories default to true if they're used. I can make a PR if you agree this is the way to go.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions