Copy-webpack-plugin: ignore is not working

Created on 31 May 2016  Â·  13Comments  Â·  Source: webpack-contrib/copy-webpack-plugin

I am trying to move all files from my current folder to dist folder. node_modules is also present in current folder. I was trying to ignore node_modules folder whiile copying. I have used the following snippet:
new CopyWebpackPlugin( [ { from: '.' } ], { ignore: [ 'node_modules' ] } )

And this is not at all working

Most helpful comment

ignore bug

not ignore folders

image

image


copy-webpack-plugin ignore folder

https://github.com/webpack-contrib/copy-webpack-plugin/issues/54

OK

ignore folder & any thing in the folder === "libs/**/*"

ignore some .extension files === ["*.md", "*.js", "*.css" ]

// ignore folder & any thing in the folder === "libs/**/*"
// ignore some .extension files === ["*.md", "*.js", "*.css" ]

    new CopyWebpackPlugin([
        {
            from: "./src/backend-system/",
            to: "../",
            ignore: ["*.md", "*.js", "*.css", "others/*", "libs/**/*"]
        },
        {
            from: "./src/backend-system/index.css",
            to: "./css/"
        }
    ]),

image

image

All 13 comments

Got the issue. My configuration was wrong. the correct configuration is:
new CopyWebpackPlugin( [ { from: '.' } ], { ignore: [ 'node_modules/*' ] } )

Closing the issue!

it worked but, it is keeping folders. it is avoiding only files. Is there a way to avoid everything include the node_modules folder itself?

So, you're almost there. To get it to work today, try:
new CopyWebpackPlugin( [ { from: '.' } ], { ignore: [ 'node_modules/**/*' ] } )

I guess it could be made a bit cleaner. Most of the time, if someone passes something that looks like a directory, they want to exclude everything in that directory, so in the future, you could use something like this:
new CopyWebpackPlugin( [ { from: '.' } ], { ignore: [ 'node_modules' ] } )

@kevlened nope. This is still keeping folders :(
I dont want the 'node_modules' folder at all...

Make sure to clean your build directory. Webpack doesn't clean it before copying things to it, so you may see old folders. Another possibility is some of the folders have files that start with dots. We'll ignore those too:

new CopyWebpackPlugin([{ from: '.' }], {
    ignore: [{
        dots: true,
        glob: 'node_modules/**/*'
    }]
})

I should make this easier, or add it to the docs as an example

Hurray It worked! but a minor correction! it should be dot: true not dots: true

But, lets have the enhancement! that helps! :)

This is now the default in v4.0.0. Thanks for filing the issue!

That's great, @kevlened :)

@kevlened You saved us a lot of trouble. Thanks!

ignore bug

not ignore folders

image

image


copy-webpack-plugin ignore folder

https://github.com/webpack-contrib/copy-webpack-plugin/issues/54

OK

ignore folder & any thing in the folder === "libs/**/*"

ignore some .extension files === ["*.md", "*.js", "*.css" ]

// ignore folder & any thing in the folder === "libs/**/*"
// ignore some .extension files === ["*.md", "*.js", "*.css" ]

    new CopyWebpackPlugin([
        {
            from: "./src/backend-system/",
            to: "../",
            ignore: ["*.md", "*.js", "*.css", "others/*", "libs/**/*"]
        },
        {
            from: "./src/backend-system/index.css",
            to: "./css/"
        }
    ]),

image

image

@xgqfrms – thank you! "folderName/**/*" to ignore folder AND its contents

@miked1ck You are welcome!

ignore bug

not ignore folders

image

image

copy-webpack-plugin ignore folder

54

OK

ignore folder & any thing in the folder === "libs/**/*"

ignore some .extension files === ["*.md", "*.js", "*.css" ]

// ignore folder & any thing in the folder === "libs/**/*"
// ignore some .extension files === ["*.md", "*.js", "*.css" ]

    new CopyWebpackPlugin([
        {
            from: "./src/backend-system/",
            to: "../",
            ignore: ["*.md", "*.js", "*.css", "others/*", "libs/**/*"]
        },
        {
            from: "./src/backend-system/index.css",
            to: "./css/"
        }
    ]),

image

image

Worked for me.. Thanks.. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jbruni picture jbruni  Â·  3Comments

RPDeshaies picture RPDeshaies  Â·  5Comments

BoldBigflank picture BoldBigflank  Â·  6Comments

Jocs picture Jocs  Â·  4Comments

padinko picture padinko  Â·  3Comments