Skip to content

Copying dotfile .env creates directory instead of file, toType:'file' triggers EISDIR, templates fail schema validation #811

@bhanuprakashbahoju

Description

@bhanuprakashbahoju

Bug Description

When copying a dotfile like .env to the output root:

It creates a .env/ directory and places the file inside as .env/.env.
Adding toType: 'file' resolves the dir creation but throws EISDIR: illegal operation on a directory, open '/path/to/build/.env' (tries to open the pre-created dir as a file).
Using to: '[name][ext]' with toType: 'template' fails schema validation: options.patterns[X].to should be a string | function.
globOptions: { dot: true } and absolute from: path.resolve(__dirname, '.env') don't help

Link to Minimal Reproduction and step to reproduce

{
from : '.env',
to : '.env',
globOptions: { dot: true },
noErrorOnMissing: true
}

Expected Behavior

Should copy the file without creating an extra directory node

Actual Behavior

creates and extra directory with the dot file name and place the dot file inside that folder

Environment

Packages:
"copy-webpack-plugin": "^13.0.1",

Is this a regression?

None

Last Working Version

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions