§001§ Webpack 5的Plugin——CopyWebpackPlugin

89 阅读1分钟

1. 问题:在一个打包生成的文件夹里有多个index.html文件(打包生成一个index.html和使用该插件复制生成一个index.html产生冲突)

plugins: [
new CopyWebpackPlugin({
  patterns:[
    {
      from:"public",
      globOptions:{
        ignore:[
          "index.html",
          ".DS_Store",
          "test.txt"
        ]
      }
    }
  ]
})
]

ERROR in Conflict: Multiple assets emit different content to the same filename index.html

2. 解决方案:使用省略方法

plugins: [
new CopyWebpackPlugin({
  patterns:[
    {
      from:"public",
      globOptions:{
        ignore:[
          "**/index.html",
          ".DS_Store",
          "test.txt"
        ]
      }
    }
  ]
})
]