Open 60late opened 10 months ago
I'm using vite-vue2@1.0.0 including this plugin , the build result show error: TypeError: Intl.Segmenter is not a constructor. What happend to this? How should i fix this?
I'm using vite-vue2@1.0.0 including this plugin , the build result show error: TypeError: Intl.Segmenter is not a constructor. What happend to this? How should i fix this?
This is an incompatibility with Node.js 14. Please consider upgrading your Runtime Node.js to 16+ (recommend v18+) @lish1986
Great. It works. I upgrade Node to v16.20.0. The build speed is faster than vite-plugin-imagemin. Thanks a lot!
vite-plugin-compression2、vite-plugin-compression这种压缩插件,会在使用本插件转换图片格式并替换原文件之前进行压缩。
minipic({
sharpOptions: {
avif: {
lossless: true,
},
},
convert: [
{ from: 'webp', to: 'avif' },
{ from: 'png', to: 'avif' },
{ from: 'jpg', to: 'avif' },
{ from: 'jpeg', to: 'avif' },
],
})
如图所示:
目前解决办法是在压缩插件中排除常见的图片格式,未来是否可以解决这个问题,或者说像webp,avif等新的web图像格式已经不需要再用gz等压缩算法等去优化体积。
vite-plugin-compression2、vite-plugin-compression这种压缩插件,会在使用本插件转换图片格式并替换原文件之前进行压缩。
minipic({ sharpOptions: { avif: { lossless: true, }, }, convert: [ { from: 'webp', to: 'avif' }, { from: 'png', to: 'avif' }, { from: 'jpg', to: 'avif' }, { from: 'jpeg', to: 'avif' }, ], })
如图所示:
目前解决办法是在压缩插件中排除常见的图片格式,未来是否可以解决这个问题,或者说像webp,avif等新的web图像格式已经不需要再用gz等压缩算法等去优化体积。
@yangxu52 你好,gzip压缩一般只针对html,css和js,一般不用于图片文件,所以未来不会增加对这方面的支持 原因可以参考这篇文章 https://zhuanlan.zhihu.com/p/664651731
1.插件安装不成功(Install failed) 由于wall的原因,部分地区无法直接请求github上的镜像资源
在你全局或者项目的目录的.npmrc文件中增加以下内容
2.打包时报错(require() of ES Module XX from XX not supported.) 是由于本插件引用的chalk,boxen等插件都是基于es module的 在package.json中加入以下代码可以解决
或者,你可以把
vite.config.js
文件的后缀名修改为mjs
,这个方法同样奏效3.Public文件夹下的文件没有被压缩(Images in /public folder will not be compressed) 该问题已修复,把插件升级至>v1.1.0版本
4.run buid 报错Error: ENOENT: no such file or directory 该问题已修复,把插件升级至>=v1.1.3版本