Vue3+Vite4
生产环境静态资源加载失败,报404,发现是中文文件名导致。
解决如下:
在vite.config.ts中
build.rollupOptions.output下加入
assetFileNames:(assetInfo)=>{
if(/[\u4E00-\u9FA5]/.test(assetInfo.name)){
return 'assets/[hash]-[hash][extname]'
}else{
return 'assets/[name]-[hash][extname]'
}
}