解决在配置copy-webpack-plugin插件时报错

配置如下:

new CopyWebpackPlugin({
            from: path.resolve(__dirname, './src/assets'),
            to: 'assets'
        })

报错信息

ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
解决在配置copy-webpack-plugin插件时报错_第1张图片

错误分析

报错信息的大概意思是说我们的配置对象缺少patterns数组,该数组包含多个对象{from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }

解决方案

new CopyWebpackPlugin({
            patterns: [
                {from: path.resolve(__dirname, './src/assets'), to: 'assets'}
            ]
        })

你可能感兴趣的:(解决在配置copy-webpack-plugin插件时报错)