CopyWebpackPlugin usage question



  • Hi! Can’t copy robots.txt on quasar build with CopyWebpackPlugin. I’ve just copy-paste from there, but there is an error:

    app:webpack Extending SPA Webpack config +493ms
    (node:15489) UnhandledPromiseRejectionWarning:   ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
       - options[0] misses the property 'patterns'. Should be:
         [non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
    

    What I’m doing wrong? Help pls!



  • Hi,
    Did you find the solution?
    I have the same problem and I still managed to find the solution.
    Thank you in advance.



  • This might be because you’ve updated to a newer version. What solved it for me was changing from:

        const CleanWebpackPlugin = require('clean-webpack-plugin');
    
        ...
        
        plugins: [
            new CleanWebpackPlugin(),
            new MiniCssExtractPlugin({
                filename: "css/[name].bundle.css",
                chunkFilename: "css/[name][id].bundle.css"
            }),
            new CopyWebpackPlugin([{
                from: path.resolve(__dirname, '../src/static')
            }])
        ],
    
    to:
        const { CleanWebpackPlugin } = require('clean-webpack-plugin');
    
        ...
    
        plugins: [
            new CopyWebpackPlugin({
                patterns: [
                    {from: path.resolve(__dirname, '../src/static')}
                ]
            })
        ],
    

    See: https://webpack.js.org/plugins/copy-webpack-plugin/


Log in to reply