• 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

    运行成功

  • 相关阅读:
    给你的R语言再次提速
    golang设计模式——设计原则
    2022-06-26 笔记本新机重装系统
    webpack--加载器(loader)
    小程序引入隐私政策
    GitHub配置SSH Keys步骤
    Gradle学习(从0到1精通)
    Llama 2 来袭 - 在 Hugging Face 上玩转它
    【ppt技巧】将幻灯片里的图片背景设置为透明
    带你认识设计模式的【策略模式】及优缺点
  • 原文地址:https://blog.csdn.net/weixin_42821697/article/details/126341346