0.6.1 • Published 2 years ago
vite-plugin-imagemin v0.6.1
vite-plugin-imagemin
English | 中文
A vite plugin for compressing image assets
Install (yarn or npm)
node version: >=12.0.0
vite version: >=2.0.0
yarn add vite-plugin-imagemin -D
or
npm i vite-plugin-imagemin -D
China installation note
Because imagemin is not easy to install in China. Several solutions are now available
- Use yarn to configure in package.json (recommended)
"resolutions": {
"bin-wrapper": "npm:bin-wrapper-china"
},
- Use npm, add the following configuration to the computer host file
199.232.4.133 raw.githubusercontent.com
- Install with cnpm (not recommended)
Usage
- Configuration plugin in vite.config.ts
import viteImagemin from 'vite-plugin-imagemin';
export default () => {
return {
plugins: [
viteImagemin({
gifsicle: {
optimizationLevel: 7,
interlaced: false,
},
optipng: {
optimizationLevel: 7,
},
mozjpeg: {
quality: 20,
},
pngquant: {
quality: [0.8, 0.9],
speed: 4,
},
svgo: {
plugins: [
{
name: 'removeViewBox',
},
{
name: 'removeEmptyAttrs',
active: false,
},
],
},
}),
],
};
};
Options
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 |
Example
Run Example
cd ./example
yarn install
yarn build
Sample project
License
MIT
Inspiration
0.5.3
2 years ago
0.5.0
2 years ago
0.6.1
2 years ago
0.5.2
2 years ago
0.6.0
2 years ago
0.5.1
2 years ago
0.4.6
3 years ago
0.4.5
3 years ago
0.4.4
3 years ago
0.4.3
3 years ago
0.4.2
3 years ago
0.4.1
3 years ago
0.4.0
3 years ago
0.3.2
3 years ago
0.3.1
3 years ago
0.3.0
3 years ago
0.2.9
3 years ago
0.2.8
3 years ago
0.2.7
3 years ago
0.2.6
3 years ago
0.2.5
3 years ago
0.2.4
3 years ago
0.2.3
3 years ago
0.2.1
3 years ago
0.2.0
3 years ago
0.2.2
3 years ago
0.1.0
3 years ago