Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CopyWebpackPlugin - ignore a folder

Using CopyWebpackPlugin, I am not able to ignore a specific folder or a specific file. It copies everything.

What I have done in the webpack.config.js:

    new CopyWebpackPlugin([
        {
            from: 'src/assets',
            to: 'assets',
            ignore: ['src/assets/img/folder/test.png']
        },
    ]),

I also tried like that:

    new CopyWebpackPlugin([
        {
            from: 'src/assets',
            to: 'assets',
            ignore: ['src/assets/img/folder/*']
        },
    ]),

Regarding the readme I think I am doing right.

like image 279
PierBJX Avatar asked Jun 19 '19 14:06

PierBJX


2 Answers

New versions of CopyWebpackPlugin have changed the way of ignoring files.

new CopyWebpackPlugin({
    patterns: [{
        from: defaultSourcePath,
        globOptions: {
            ignore: [
                '**/css/my.css',
                '**/js/my.js',
                '**/index.html'
            ]
        }
    }]
})
like image 154
Felipe Desiderati Avatar answered Oct 03 '22 03:10

Felipe Desiderati


Try this:

ignore: ['img/folder/**/*']

This will not copy the entire img/folder.

Remember to clear your destination folder before running your webpack.

like image 45
Arun Avatar answered Oct 03 '22 04:10

Arun