关于vite自动压缩图片的问题
在使用 vben 后台系统的时候,发现打包后的登录页大图十分模糊!显然是 vite 打包时进行了压缩操作,进一步发现原来是 imagemin 插件在作祟,前往根目录下build\vite\plugin路径修改配置,实现图片不被压缩!
在 vben 源码中已给出 imagemin 文档链接:https://github.com/anncwb/vite-plugin-imagemin ,配置如下:
| params | type | default | default |
|---|---|---|---|
| verbose | boolean |
true |
Whether to output the compressed result in the console |
| filter | RegExp or (file: string) => boolean |
- | Specify which resources are not compressed |
| disable | boolean |
false |
Whether to disable |
| svgo | object or false |
- | See Options |
| gifsicle | object or false |
- | See Options |
| mozjpeg | object or false |
- | See Options |
| optipng | object or false |
- | See Options |
| pngquant | object or false |
- | See Options |
| webp | object or false |
- | See Options |
我们需要关注的是 filter 属性,它允许我们定义文件是否被压缩。
于是有以下代码:
1 | |
以上!
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!