Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore a folder or a file #388

Closed
PierBJX opened this issue Jun 19, 2019 · 3 comments · Fixed by #410
Closed

Ignore a folder or a file #388

PierBJX opened this issue Jun 19, 2019 · 3 comments · Fixed by #410

Comments

@PierBJX
Copy link

PierBJX commented Jun 19, 2019

  • Operating System: Windows 10
  • Node Version: 10.15.3
  • NPM Version: 6.4.1
  • webpack Version: 4
  • copy-webpack-plugin Version: 5.0.3

Expected Behavior

To ignore the folder or the file specifies in the options.

Actual Behavior

It copies everything, even the ignore array path.

Code

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

I also tried to ignore the folder like that.

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

How Do We Reproduce?

Here is my full webpack.config.js

module.exports = {
    entry: {
        page1: './src/page1/main.js',
        page2: './src/page2/main.js',
    },
    output: {
        path: path.resolve(__dirname, 'dist'), // output directory
        filename: '[name].js', // name of the generated bundle
        publicPath: '/'
    },
    module: {
        rules: [
            // Babel
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
                options: {
                    presets: ['@babel/preset-env']
                }
            },
            // HTML loader
            {
                test: /\.html$/,
                use: [
                    {
                        loader: "html-loader",
                        options: { minimize: true }
                    }
                ]
            },
            // SCSS & CSS
            {
                test: /\.s?[ac]ss$/,
                use: [
                    {
                        loader: MiniCssExtractPlugin.loader,
                    },
                    { loader: 'css-loader' },
                    {
                        // Loader for webpack to process CSS with PostCSS
                        loader: 'postcss-loader',
                        options: {
                            plugins: function () {
                                return [
                                    require('autoprefixer')
                                ];
                            }
                        }
                    },
                    { loader: 'sass-loader' }
                ],
            },
            // File loader
            {
                test: /\.(woff(2)?|ttf|eot|png|svg)(\?v=\d+\.\d+\.\d+)?$/,
                use: [
                    {
                        loader: 'file-loader',
                        options: {
                            limit: 8192,
                            outputPath: '/assets'
                        },
                    }
                ]
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './src/index.html',
            inject: true,
            chunks: ['page1'],
            filename: 'index.html'
        }),
        new HtmlWebpackPlugin({
            template: './src/page2/index.html',
            inject: true,
            chunks: ['page2'],
            filename: 'page2/index.html'
        }),
        new MiniCssExtractPlugin({
            filename: '[name].css',
            chunkFilename: '[id].css',
        }),
        new FaviconsWebpackPlugin('./src/assets/img/favicons/fav.png')
    ]
};
@alexander-akait
Copy link
Member

Please provide minimum reproducible test repo, looks you have invalid ignore value

@PierBJX
Copy link
Author

PierBJX commented Jun 24, 2019

Fixed here

@alexander-akait
Copy link
Member

👍 Maybe we should documented this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants