Copy-webpack-plugin: An exception on /**/* path with nested folders

Created on 16 Feb 2016  路  5Comments  路  Source: webpack-contrib/copy-webpack-plugin

When using path like assets/ * * / * to copy a number of files in nested folders, an exception is occured:
A global exception occured: { [Error: EINVAL: invalid argument, read] errno: -4071, code: 'EINVAL', syscall: 'read' }
A number of messages with exception match total number of nested folders, so seems like folders are causing it.
But files and folders are still copied successfully, if to handle global exceptions manually.

Replacing path with assets/ * * / * . * fixes issue. But probably this workaround would't work for files without extension.

Bug

Most helpful comment

I have a similar issue? Don't know what went wrong.

My file structure:

src
    assets
        fonts
    img
webpack.config.js

My plugin:

{from: 'src/assets/**/*', to: 'assets'}

With this Webpack output path:

output: {
    path: path.join(__dirname, 'public')
}

Results in:

public
    assets
        src
        assets
            fonts

But, if I use this plugin:

{from: 'src/assets/fonts', to: 'assets/fonts'}

I get the desired output:

public
    assets
        fonts

All 5 comments

+1 this just bit me too.

I have a similar issue? Don't know what went wrong.

My file structure:

src
    assets
        fonts
    img
webpack.config.js

My plugin:

{from: 'src/assets/**/*', to: 'assets'}

With this Webpack output path:

output: {
    path: path.join(__dirname, 'public')
}

Results in:

public
    assets
        src
        assets
            fonts

But, if I use this plugin:

{from: 'src/assets/fonts', to: 'assets/fonts'}

I get the desired output:

public
    assets
        fonts

Not sure why this has closed, this just happened to me too on webpack4.

When using a glob pattern in the from path: path/**/* it copys the dir structure over to theto path.

It appears that just stating the directory as @MatthewKosloski has done, it will glob the files within anyway.

@joepagan Can you create minimum reproducible test repo?

@evilebottnawi Of course!

This maybe because it's on webpack-dev-server? The others didn't say. I have seen the large issue where some users want the files to exist when running dev server, though I am happy for these images to be in the memory.

Here is the repo for you:
https://github.com/joepagan/webpack-copywebpackplugin-glob-issue

just clone, yarn; yarn start

Visit:
http://localhost:8080/webpack-dev-server

image

Now comment out the glob rules in webpack.common.js lines 94-97, and, uncomment 98-101

The paths are then as expected:
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kimgysen picture kimgysen  路  3Comments

alexprice1 picture alexprice1  路  5Comments

alex88 picture alex88  路  4Comments

nickenchev picture nickenchev  路  3Comments

jbruni picture jbruni  路  3Comments