vite-plugin-min-jpg
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published
  1. 这是一个 vite 插件,用来压缩 jpg,其他的都不支持
  2. import 导入后,就可以在 vite 的 plugin 配置项目里添加了。
  3. imageCompressionPlugin 的第一个参数是你 build 完之后 jpg 的存放路径,比如我项目的 build 之后存放的路径是 dist/static/jpg 。 第二个参数就是压缩参数:100 为不压缩 , 默认压缩 50
  4. 优点:这个包使用 images,对底层兼容性好。在某些 docker 环节上,imagemin 这个库用起来有很多兼容性问题,所以开发了这个库。
  5. 可惜的是,目前只支持 jpg

This is a Vite plugin designed to compress JPEG images, and it does not support other formats. Once imported, you can add it to the Vite plugin configuration. The first parameter of the imageCompressionPlugin is the path where your built JPEG files are stored after the build process. For example, if the path in your project after the build is dist/static/jpg, that would be the first parameter. The second parameter is the compression setting: 100 for no compression, and the default is 50. Advantages: This package uses the images library, which has good compatibility at the lower level. In certain Docker environments, the imagemin library has many compatibility issues, so this library was developed to address those concerns. Unfortunately, it currently only supports JPEG compression.

example:

import imageCompressionPlugin from "vite-plugin-min-jpg";
export default defineConfig({
	plugins:[
		imageCompressionPlugin("dist/static/jpg" , 50)
 	]
})

Package Sidebar

Install

npm i vite-plugin-min-jpg

Weekly Downloads

0

Version

2.0.1

License

ISC

Unpacked Size

7.29 kB

Total Files

6

Last publish

Collaborators

  • gigity