@rsbuild/plugin-image-compress
Advanced tools
+4
-1
@@ -9,3 +9,6 @@ import type { Codec, Codecs } from './types.js'; | ||
| export declare const svgCodec: Codec<'svg'>; | ||
| declare const codecs: Record<Codecs, Codec<any>>; | ||
| type CodecMap = { | ||
| [K in Codecs]: Codec<K>; | ||
| }; | ||
| declare const codecs: CodecMap; | ||
| export default codecs; |
+18
-25
| { | ||
| "name": "@rsbuild/plugin-image-compress", | ||
| "version": "1.3.3", | ||
| "version": "1.3.4", | ||
| "repository": "https://github.com/rstackjs/rsbuild-plugin-image-compress", | ||
@@ -20,19 +20,5 @@ "license": "MIT", | ||
| ], | ||
| "scripts": { | ||
| "build": "rslib", | ||
| "dev": "rslib -w", | ||
| "lint": "biome check .", | ||
| "lint:write": "biome check . --write", | ||
| "prepare": "simple-git-hooks && npm run build", | ||
| "test": "playwright test", | ||
| "bump": "npx bumpp" | ||
| }, | ||
| "simple-git-hooks": { | ||
| "pre-commit": "npx nano-staged" | ||
| "pre-commit": "pnpm run lint:write" | ||
| }, | ||
| "nano-staged": { | ||
| "*.{js,jsx,ts,tsx,mjs,cjs}": [ | ||
| "biome check --write --no-errors-on-unmatched" | ||
| ] | ||
| }, | ||
| "dependencies": { | ||
@@ -43,9 +29,9 @@ "@napi-rs/image": "1.11.2", | ||
| "devDependencies": { | ||
| "@biomejs/biome": "^1.9.4", | ||
| "@playwright/test": "^1.59.1", | ||
| "@rsbuild/core": "^2.0.0", | ||
| "@rslib/core": "^0.21.3", | ||
| "@types/node": "^24.12.2", | ||
| "nano-staged": "^1.0.2", | ||
| "playwright": "^1.59.1", | ||
| "@playwright/test": "^1.60.0", | ||
| "@rsbuild/core": "^2.0.6", | ||
| "@rslib/core": "^0.21.5", | ||
| "@rslint/core": "^0.5.3", | ||
| "@types/node": "^24.12.4", | ||
| "playwright": "^1.60.0", | ||
| "prettier": "^3.8.3", | ||
| "simple-git-hooks": "^2.13.1", | ||
@@ -62,7 +48,14 @@ "typescript": "6.0.3" | ||
| }, | ||
| "packageManager": "pnpm@10.33.1", | ||
| "publishConfig": { | ||
| "access": "public", | ||
| "registry": "https://registry.npmjs.org/" | ||
| }, | ||
| "scripts": { | ||
| "build": "rslib", | ||
| "dev": "rslib -w", | ||
| "lint": "rslint && prettier -c .", | ||
| "lint:write": "rslint --fix && prettier -w .", | ||
| "test": "playwright test", | ||
| "bump": "npx bumpp" | ||
| } | ||
| } | ||
| } |
+21
-21
@@ -27,3 +27,3 @@ # @rsbuild/plugin-image-compress | ||
| // rsbuild.config.ts | ||
| import { pluginImageCompress } from "@rsbuild/plugin-image-compress"; | ||
| import { pluginImageCompress } from '@rsbuild/plugin-image-compress'; | ||
@@ -42,7 +42,7 @@ export default { | ||
| ```js | ||
| pluginImageCompress(["jpeg", "png", "ico"]); | ||
| pluginImageCompress(['jpeg', 'png', 'ico']); | ||
| ``` | ||
| ```js | ||
| pluginImageCompress([{ use: "jpeg" }, { use: "png" }, { use: "ico" }]); | ||
| pluginImageCompress([{ use: 'jpeg' }, { use: 'png' }, { use: 'ico' }]); | ||
| ``` | ||
@@ -76,13 +76,13 @@ | ||
| // Options for @napi-rs/image `compressJpeg` method | ||
| { use: "jpeg", test: /\.(?:jpg|jpeg|jpe)$/ }, | ||
| { use: 'jpeg', test: /\.(?:jpg|jpeg|jpe)$/ }, | ||
| // Options for @napi-rs/image `pngQuantize` method | ||
| { use: "png", minQuality: 50 }, | ||
| { use: 'png', minQuality: 50 }, | ||
| // Options for @napi-rs/image `avif` method | ||
| { use: "avif", quality: 80 }, | ||
| { use: 'avif', quality: 80 }, | ||
| // Options for @napi-rs/image `webp` method | ||
| { use: "webp", quality: 80 }, | ||
| { use: 'webp', quality: 80 }, | ||
| // Options for svgo | ||
| { use: "svg", floatPrecision: 2 }, | ||
| { use: 'svg', floatPrecision: 2 }, | ||
| // No options yet | ||
| { use: "ico" }, | ||
| { use: 'ico' }, | ||
| ]); | ||
@@ -98,3 +98,3 @@ ``` | ||
| ```js | ||
| pluginImageCompress(["jpeg", "pngLossless", "ico"]); | ||
| pluginImageCompress(['jpeg', 'pngLossless', 'ico']); | ||
| ``` | ||
@@ -107,3 +107,3 @@ | ||
| ```js | ||
| pluginImageCompress(["jpeg", "pngLossless", "ico", "png"]); | ||
| pluginImageCompress(['jpeg', 'pngLossless', 'ico', 'png']); | ||
| ``` | ||
@@ -119,18 +119,18 @@ | ||
| // rspack.config.mjs | ||
| import { ImageMinimizerPlugin } from "@rsbuild/plugin-image-compress"; | ||
| import { defineConfig } from "@rspack/cli"; | ||
| import { ImageMinimizerPlugin } from '@rsbuild/plugin-image-compress'; | ||
| import { defineConfig } from '@rspack/cli'; | ||
| export default defineConfig({ | ||
| mode: process.env.NODE_ENV === "production" ? "production" : "development", | ||
| mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', | ||
| optimization: { | ||
| minimizer: [ | ||
| // Use `...` to preserve the default JS and CSS minimizers of Rspack | ||
| "...", | ||
| '...', | ||
| // Add the image minimizer plugins | ||
| new ImageMinimizerPlugin({ | ||
| use: "jpeg", | ||
| use: 'jpeg', | ||
| test: /\.(?:jpg|jpeg)$/, | ||
| }), | ||
| new ImageMinimizerPlugin({ | ||
| use: "png", | ||
| use: 'png', | ||
| test: /\.png$/, | ||
@@ -140,3 +140,3 @@ maxQuality: 50, | ||
| new ImageMinimizerPlugin({ | ||
| use: "avif", | ||
| use: 'avif', | ||
| test: /\.avif$/, | ||
@@ -146,3 +146,3 @@ quality: 80, | ||
| new ImageMinimizerPlugin({ | ||
| use: "webp", | ||
| use: 'webp', | ||
| test: /\.webp$/, | ||
@@ -152,3 +152,3 @@ quality: 80, | ||
| new ImageMinimizerPlugin({ | ||
| use: "svg", | ||
| use: 'svg', | ||
| test: /\.svg$/, | ||
@@ -158,3 +158,3 @@ floatPrecision: 2, | ||
| new ImageMinimizerPlugin({ | ||
| use: "ico", | ||
| use: 'ico', | ||
| test: /\.(?:ico|icon)$/, | ||
@@ -161,0 +161,0 @@ }), |
521
0.58%26289
-0.6%