https://github.com/adrienbaron/nuxt-asset-name-collision-bug
Nuxt seems to copy all the images to /_nuxt/img, but doesn't add a hash of the file at the end of the name. So images with the same name but in different folders collides.
Currently Nuxt will flat all built resources by default.
With #3787, you can config build.filenames.img as what you want, for example:
build: {
filenames: {
img: (file) => {
const dir = path.dirname(file).replace('assets', 'img')
return `${dir}/[name].[hash:7].[ext]`
}
}
}
@clarkdo Doesn't seem to resolve the issue, the issue only happens in dev mode, in regular build mode the hashing is applied and there is no problem.
It because in dev mode, we removed all hash because it has some problems as https://github.com/webpack/webpack/issues/1914#issuecomment-174171709 described.
If you use the function filename similar to above one, if will generate images into different directories.
The easiest way should be that rename the images, but it may not that reasonable, or we can replace [hash] to [path][name] in dev mode, maybe we just need to use custom filenames for production, how do you think @Atinux ?
And this only happened in img font video which are loaded by file-loader, because other resources like chunk, their [name] has been converted to flat names by webpackChunkName comment
@clarkdo Ok makes sense. Using the path in dev mode seems like a good compromise? Would still store if the user moves files around probably though... Not sure how much this is an issue.
Worse case we could just disallow files with same name in assets and add a warning in the doc?
Fixed by #3789
Using path in dev mode now.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.