Vite开发Vue项目时,打包后将图片替换成CDN链接
00 min
2023-3-2
2024-7-18
type
status
date
slug
summary
tags
category
icon
password
😀
在使用 Vite 打包 Vue 项目时,可以使用 Vite 的构建钩子 build:before 来实现将图片引用地址修改为 CDN 地址的功能。 在 beforeWrite.writeBundle 函数中,使用 glob 包获取构建后的文件列表,遍历文件列表,查找并替换所有引用的图片路径。
 
上一篇
2024年|ESlint9+Prettier从0开始配置教程
下一篇
Mac 下 husky 无效问题解决