reactjs 在React应用程序中更新copy-webpack-plugin和webpack后,文件未被复制

kmynzznz  于 2023-04-20  发布在  React
关注(0)|答案(1)|浏览(91)

以前的dev依赖关系:

{
  ...
   "webpack": "^4.14.0",
   "webpack-cli": "3.0.8",
   "webpack-dev-middleware": "3.1.3",
   "copy-webpack-plugin": "^5.0.5",
}

现已更新为

{
    ...
    "webpack": "^5.79.0",
    "webpack-cli": "^4.5.0",
    "webpack-dev-middleware": "^6.0.2",
    "webpack-dev-server": "^4.13.3",
    "webpack-hot-middleware": "^2.25.3",
    "copy-webpack-plugin": "^11.0.0"
}

在以前的版本中,文件被复制
webpack.base.config.js
new CopyWebpackPlugin([path.join(process.cwd(), 'app/workers/worker.js')])
现已更新

new CopyPlugin({
      patterns: [
        {
          from: path.join(process.cwd(), 'app/workers/worker.js'),
          to: 'workers',
        },
      ],
    }),

完全没有被复制。
我尝试将输出文件夹更改为“/”或path.join(process.cwd(), 'app/workers/worker.js')"仍然不起作用

8i9zcol2

8i9zcol21#

在我去掉“to”部分后,它现在可以工作了

new CopyPlugin({
      patterns: [
        {
          from: path.join(process.cwd(), 'app/workers/worker.js'),
        },
      ],
    }),

相关问题