• ERROR Error: [copy-webpack-plugin] patterns must be an array


    安装mars3D时需要安装copy-webpack-plugin插件
    然后在vue.config.js进行配置 运行报错ERROR Error: [copy-webpack-plugin] patterns must be an array
    pattern必须是一个数组
    当前node版本为12.2.0

    const plugins = [
                // 标识cesium资源所在的主目录,cesium内部资源加载、多线程等处理时需要用到
                new webpack.DefinePlugin({
                    CESIUM_BASE_URL: JSON.stringify(path.join(config.output.publicPath, cesiumRunPath))
                }),
                // Cesium相关资源目录需要拷贝到系统目录下面(部分CopyWebpackPlugin版本的语法可能没有patterns)
               new CopyWebpackPlugin({
                    patterns: [
                    { from: path.join(cesiumSourcePath, 'Workers'), to: path.join(config.output.path, cesiumRunPath, 'Workers') },
                    { from: path.join(cesiumSourcePath, 'Assets'), to: path.join(config.output.path, cesiumRunPath, 'Assets') },
                    { from: path.join(cesiumSourcePath, 'ThirdParty'), to: path.join(config.output.path, cesiumRunPath, 'ThirdParty') },
                    { from: path.join(cesiumSourcePath, 'Widgets'), to: path.join(config.output.path, cesiumRunPath, 'Widgets') }
                    ]
                })
            ];
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    new CopyWebpackPlugin改为如下

    const plugins = [
                // 标识cesium资源所在的主目录,cesium内部资源加载、多线程等处理时需要用到
             new webpack.DefinePlugin({
                    CESIUM_BASE_URL: JSON.stringify(path.join(config.output.publicPath, cesiumRunPath))
             }),
             new CopyWebpackPlugin([
    	        { from: path.join(cesiumSourcePath, 'Workers'), to: path.join(config.output.path, cesiumRunPath, 'Workers') },
    	        { from: path.join(cesiumSourcePath, 'Assets'), to: path.join(config.output.path, cesiumRunPath, 'Assets') },
    	        { from: path.join(cesiumSourcePath, 'ThirdParty'), to: path.join(config.output.path, cesiumRunPath, 'ThirdParty') },
    	        { from: path.join(cesiumSourcePath, 'Widgets'), to: path.join(config.output.path, cesiumRunPath, 'Widgets') }
            ])
     ];
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    运行成功

  • 相关阅读:
    目标检测指标AP50/准确率/召回率说明
    DeFi 对经济模式带来的改变和存在的局限
    RDMA 优势
    HTML5+CSS3小实例:水波纹按钮效果
    路由守卫的参数to,from,next是什么?怎么用?
    位置式PID
    python28种极坐标绘图函数总结
    一张逻辑图讲清楚OS在做什么:浅谈OS
    MFC扩展库BCGControlBar Pro v35.0新版亮点:重新设计的工具栏编辑器等
    创业者关注的聚合代驾平台是什么?
  • 原文地址:https://blog.csdn.net/weixin_42821697/article/details/126341346