Antecedentes: actualice vue-cli5 + use el complemento copy-plugin
Mensaje de error: Multiple assets emit different content to the same filename index.html
Clave:
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
} )
}
Problema: se generan archivos index.html duplicados y index.html no se filtra en la modificación de parámetros del complemento de copia, lo que genera copias duplicadas.
Solución: modifique el parámetro ignorar para filtrar el archivo 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
} )
}