vue-cli5升级:Multiple assets emit different content to the same filename index.html编译报错

博客围绕vue-cli5升级及使用copy-plugin插件展开。升级过程中出现生成重复index.html文件的问题,原因是在copy-plugin参数修改时未过滤index.html,导致重复拷贝。最终通过修改ignore参数过滤index.html文件解决该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. 背景:升级vue-cli5 + 使用copy-plugin插件
  2. 报错信息:Multiple assets emit different content to the same filename index.html
  3. 关键代码:
chainWebpack: (config) => {
	config.plugin('copy').tap(options => {
            if (options[0] && options[0].patterns && options[0].patterns[0]) {  
                 const copyOption = JSON.parse(JSON.stringify(options[0].patterns[0]))
                 copyOption.from = path.resolve(__dirname, 'XtionWebEngine', 'public')
                 options[0].patterns.unshift(copyOption)
            }
            return options
        })
}
  1. 问题:生成重复的index.html文件,在copy-plugin的参数修改中没有过滤掉index.html导致重复拷贝
  2. 解决:修改ignore参数过滤index.html文件
chainWebpack: (config) => {
	config.plugin('copy').tap(options => {
            if (options[0] && options[0].patterns && options[0].patterns[0]) {  
                 const copyOption = JSON.parse(JSON.stringify(options[0].patterns[0]))
                 copyOption.from = path.resolve(__dirname, 'XtionWebEngine', 'public')
                 copyOption.globOptions.ignore = [
                        '**/.DS_Store',
                        path.resolve(__dirname, 'XtionWebEngine', 'public', 'index.html').replace(/\\/g, '/')
                 ]
                 options[0].patterns.unshift(copyOption)
            }
            return options
        })
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值