2.0.1 • Published 9 months ago

@yuanjianming/unplugin-image-convert v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

✨ unplugin-image-convert

📦 Install

npm add @yuanjianming/unplugin-image-convert -D

💪 Basic Use

  • vite.config.js
import { defineConfig } from 'vite'
import viteImageConvert from '@yuanjianming/unplugin-image-convert/vite'
export default defineConfig({
    //....
    plugins: [viteImageConvert({
         test:/\.(jpe?g|png)$/,
         encodeOptions:{
              webp:{
                //   https://sharp.pixelplumbing.com/api-output#webp
              },
              avif:{
                  //   https://sharp.pixelplumbing.com/api-output#avif
              }
         }
    })],
})
  • webpack.config.js
const webpackImageConvert =require('@yuanjianming/unplugin-image-convert/webpack')

module.exports ={
    plugins:[
        webpackImageConvert({
                test:/\.(jpe?g|png)$/,
                encodeOptions:{
                    webp:{
                        //   https://sharp.pixelplumbing.com/api-output#webp
                    },
                    avif:{
                        //   https://sharp.pixelplumbing.com/api-output#avif
                    }
                }
        })
    ]
}

👨‍💻 Config

optiontypedefaultdescribe
testRegExp''Regular expression for image resource file path
encodeOptionsSharpOutputOptionwebp:{},avif:{}Support format conversion for jpeg, png, webp, avif, heif, jxl, gif, Jp2, and tif

💪 Default Config

{
                test:/\.(jpe?g|png)$/,
                encodeOptions:{
                    webp:{
                        //   https://sharp.pixelplumbing.com/api-output#webp
                    },
                    avif:{
                        //   https://sharp.pixelplumbing.com/api-output#avif
                    }
                }
}
2.0.1

9 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

11 months ago

1.0.0

11 months ago