标签: copy-webpack-plugin

copy-webpack-plugin 错误:主机定义的选项无效

使用 copy-webpack-plugin 后构建失败。webpack 和插件版本已经过兼容性测试(webpack5 cwp10) 我已经没有想法了 :( 有没有人遇到过熟悉的东西?这可能是跨模块兼容性问题吗?

进一步提供错误日志和配置代码 提前致谢

错误是

 HookWebpackError: Invalid host defined options
    at makeWebpackError (/home/egeo/Source/coreon-chrome-plugin/node_modules/webpack/lib/HookWebpackError.js:49:9)
    at /home/egeo/Source/coreon-chrome-plugin/node_modules/webpack/lib/Compilation.js:2495:12
    at eval (eval at create (/home/egeo/Source/coreon-chrome-plugin/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:38:1)
    at /home/egeo/Source/coreon-chrome-plugin/node_modules/webpack/lib/Compilation.js:457:26
    at /home/egeo/Source/coreon-chrome-plugin/node_modules/copy-webpack-plugin/dist/index.js:485:13
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
-- inner error --
TypeError: Invalid host defined options
    at /home/egeo/Source/coreon-chrome-plugin/node_modules/copy-webpack-plugin/dist/index.js:481:13
    at fn (/home/egeo/Source/coreon-chrome-plugin/node_modules/webpack/lib/Compilation.js:456:9)
    at Hook.eval [as callAsync] (eval at create (/home/egeo/Source/coreon-chrome-plugin/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:36:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/egeo/Source/coreon-chrome-plugin/node_modules/tapable/lib/Hook.js:18:14)
    at cont (/home/egeo/Source/coreon-chrome-plugin/node_modules/webpack/lib/Compilation.js:2492:34)
    at /home/egeo/Source/coreon-chrome-plugin/node_modules/webpack/lib/Compilation.js:2538:10
    at /home/egeo/Source/coreon-chrome-plugin/node_modules/neo-async/async.js:2830:7
    at Object.each (/home/egeo/Source/coreon-chrome-plugin/node_modules/neo-async/async.js:2850:39)
    at Compilation.createChunkAssets (/home/egeo/Source/coreon-chrome-plugin/node_modules/webpack/lib/Compilation.js:3769:12)
    at …
Run Code Online (Sandbox Code Playgroud)

webpack copy-webpack-plugin

15
推荐指数
1
解决办法
8707
查看次数

如何在 webpack 5 中使用 flatten 设置 copy-webpack-plugin

我使用 copy-webpack-plugin 10.2.0 和 webpack 5.65.0。我想将public/js文件夹中的js文件复制到dist/js.

plugins: [
    new CopyWebpackPlugin({
        patterns:[
            {
                from:'public/js/*.js',
                to:path.resolve(__dirname, 'dist','js'),
            
            }
        ]
    })
],
Run Code Online (Sandbox Code Playgroud)

但是设置也将路径复制到dist中,它变成了dist/js/public/js。我尝试添加flatten:true但有错误

Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
 - options.patterns[0] has an unknown property 'flatten'. These properties are valid:
   object { from, to?, context?, globOptions?, filter?, transformAll?, toType?, force?, priority?, info?, transform?, noErrorOnMissing? }

Run Code Online (Sandbox Code Playgroud)

那要怎么做呢?

javascript webpack copy-webpack-plugin

6
推荐指数
1
解决办法
3931
查看次数

尝试使用 webpack 复制空文件夹时出错

使用 Webpack 和 copy-webpack-plugin 我需要在构建过程中复制整个文件夹,我有:

plugins: [
  new CopyPlugin({
    patterns: [
      { from: './src/assets', to: './assets' }
    ]
  })
]
Run Code Online (Sandbox Code Playgroud)

但是,当assets文件夹为空时,这会失败:

ERROR: unable to locate ...
Run Code Online (Sandbox Code Playgroud)

如果我将一个文件添加到资产文件夹,我将工作。

如何解决这个问题?

webpack copy-webpack-plugin

5
推荐指数
1
解决办法
2354
查看次数

compiler.getLogger 不是一个函数

copy-webpack-plugin从升级4.6.06.0.2

我改变了我的代码

plugins: [
    new CopyWebpackPlugin([{
      from: clientAssetPath,
      to: paths.STATICS,
      ignore: [ '.gitkeep' ],
    }], {
      debug: 'info'
    }),
    new HtmlWebpackPlugin({
      ...htmlPluginOptions,
    }),
    new DynamicCDNWebpackPlugin({
      resolver: unpkgResolver,
    }),
  ]
Run Code Online (Sandbox Code Playgroud)

plugins: [
    new CopyPlugin([{
      patterns: [{
        from: clientAssetPath,
        to: paths.STATICS,
        noErrorOnMissing: true
      }]
    }]),
    new HtmlWebpackPlugin({
      ...htmlPluginOptions,
    }),
    new DynamicCDNWebpackPlugin({
      resolver: unpkgResolver,
    }),
  ]
Run Code Online (Sandbox Code Playgroud)

官方网站所示

但它开始抛出以下错误: compilation.getLogger is not a function

当我调试它时,我发现错误来自 node_modules/copy-webpack-plugin/dist/index.js 在此处输入图片说明 不知道是什么问题

copy webpack webpack-dev-server copy-webpack-plugin

4
推荐指数
1
解决办法
4207
查看次数

copy-webpack-plugin 配置问题

在一个 electron.js 应用程序中,我试图根据这些指示从 node.js 调用和执行 python 脚本:https : //nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback

import { execFile } from 'child_process';

let pythonPath = '/home/marco/anaconda3/bin/python3';

execFile('./scripts/factorial.py',
  [parseInt(msg)],
  { cwd: './scripts',
    env: '/home/marco/anaconda3/bin/python3'
  },
  (error, stdout, stderr) => {
    if (error) {
      throw error;
    }
    console.log(stdout);
  }
);
Run Code Online (Sandbox Code Playgroud)

我得到这个错误:

在此处输入图片说明

评论options部分时:

execFile('./scripts/factorial.py',
  [parseInt(msg)],
  //{ cwd: './scripts',
    //env: '/home/marco/anaconda3/bin/python3'
  //},
  (error, stdout, stderr) => {
    if (error) {
      throw error;
    }
    console.log(stdout);
  }
);
Run Code Online (Sandbox Code Playgroud)

我犯了同样的错误。

按照此处找到的指示:https : //www.tutorialspoint.com/run-python-script-from-node-js-using-child-process-spawn-method 我修改了代码如下:

const { spawn } = require('child_process'); …
Run Code Online (Sandbox Code Playgroud)

python child-process node.js webpack copy-webpack-plugin

3
推荐指数
1
解决办法
2202
查看次数