@rsbuild/plugin-image-compress 0.7.0-beta.0 → 0.7.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +33 -6
- package/package.json +6 -6
- package/dist/minimizer.d.ts +0 -13
- package/dist/shared/codecs.d.ts +0 -8
- package/dist/shared/utils.d.ts +0 -2
- package/dist/types/index.d.ts +0 -34
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
+
import { JpegCompressOptions, PngQuantOptions, PNGLosslessOptions } from '@napi-rs/image';
|
|
3
|
+
import { Config } from 'svgo';
|
|
4
|
+
|
|
5
|
+
type ArrayOrNot<T> = T | T[];
|
|
6
|
+
interface CodecBaseOptions {
|
|
7
|
+
jpeg: JpegCompressOptions;
|
|
8
|
+
png: PngQuantOptions;
|
|
9
|
+
pngLossless: PNGLosslessOptions;
|
|
10
|
+
ico: Record<string, unknown>;
|
|
11
|
+
svg: Config;
|
|
12
|
+
}
|
|
13
|
+
interface BaseCompressOptions<T extends Codecs> {
|
|
14
|
+
use: T;
|
|
15
|
+
test?: ArrayOrNot<RegExp>;
|
|
16
|
+
include?: ArrayOrNot<RegExp>;
|
|
17
|
+
exclude?: ArrayOrNot<RegExp>;
|
|
18
|
+
}
|
|
19
|
+
type FinalOptionCollection = {
|
|
20
|
+
[K in Codecs]: BaseCompressOptions<K> & CodecBaseOptions[K];
|
|
21
|
+
};
|
|
22
|
+
type Codecs = keyof CodecBaseOptions;
|
|
23
|
+
type OptionCollection = {
|
|
24
|
+
[K in Codecs]: K | FinalOptionCollection[K];
|
|
25
|
+
};
|
|
26
|
+
type Options = OptionCollection[Codecs];
|
|
27
|
+
|
|
28
|
+
type PluginImageCompressOptions = Options[];
|
|
29
|
+
declare const DEFAULT_OPTIONS: Codecs[];
|
|
30
|
+
interface IPluginImageCompress {
|
|
6
31
|
(...options: Options[]): RsbuildPlugin;
|
|
7
32
|
(options: Options[]): RsbuildPlugin;
|
|
8
33
|
}
|
|
9
34
|
/** Options enable by default: {@link DEFAULT_OPTIONS} */
|
|
10
|
-
|
|
35
|
+
declare const pluginImageCompress: IPluginImageCompress;
|
|
36
|
+
|
|
37
|
+
export { DEFAULT_OPTIONS, type IPluginImageCompress, type PluginImageCompressOptions, pluginImageCompress };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-image-compress",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.2",
|
|
4
4
|
"description": "Image compress plugin for Rsbuild",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"repository": {
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@napi-rs/image": "^1.9.2",
|
|
27
27
|
"svgo": "^3.3.2",
|
|
28
|
-
"@rsbuild/shared": "0.7.0-beta.
|
|
28
|
+
"@rsbuild/shared": "0.7.0-beta.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "18.x",
|
|
32
32
|
"typescript": "^5.4.2",
|
|
33
33
|
"webpack": "^5.91.0",
|
|
34
|
-
"@rsbuild/core": "0.7.0-beta.
|
|
35
|
-
"@rsbuild/webpack": "0.7.0-beta.
|
|
36
|
-
"@scripts/test-helper": "0.7.0-beta.
|
|
34
|
+
"@rsbuild/core": "0.7.0-beta.2",
|
|
35
|
+
"@rsbuild/webpack": "0.7.0-beta.2",
|
|
36
|
+
"@scripts/test-helper": "0.7.0-beta.2"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@rsbuild/core": "^0.7.0-beta.
|
|
39
|
+
"@rsbuild/core": "^0.7.0-beta.2"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public",
|
package/dist/minimizer.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { webpack } from '@rsbuild/webpack';
|
|
2
|
-
import type { FinalOptions } from './types';
|
|
3
|
-
export declare const IMAGE_MINIMIZER_PLUGIN_NAME: "@rsbuild/plugin-image-compress/minimizer";
|
|
4
|
-
export interface MinimizedResult {
|
|
5
|
-
source: webpack.sources.RawSource;
|
|
6
|
-
}
|
|
7
|
-
export declare class ImageMinimizerPlugin {
|
|
8
|
-
name: "@rsbuild/plugin-image-compress/minimizer";
|
|
9
|
-
options: FinalOptions;
|
|
10
|
-
constructor(options: FinalOptions);
|
|
11
|
-
optimize(compiler: webpack.Compiler, compilation: webpack.Compilation, assets: Record<string, webpack.sources.Source>): Promise<void>;
|
|
12
|
-
apply(compiler: webpack.Compiler): void;
|
|
13
|
-
}
|
package/dist/shared/codecs.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Codec, Codecs } from '../types';
|
|
2
|
-
export declare const jpegCodec: Codec<'jpeg'>;
|
|
3
|
-
export declare const pngCodec: Codec<'png'>;
|
|
4
|
-
export declare const pngLosslessCodec: Codec<'pngLossless'>;
|
|
5
|
-
export declare const icoCodec: Codec<'ico'>;
|
|
6
|
-
export declare const svgCodec: Codec<'svg'>;
|
|
7
|
-
declare const codecs: Record<Codecs, Codec<any>>;
|
|
8
|
-
export default codecs;
|
package/dist/shared/utils.d.ts
DELETED
package/dist/types/index.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { Buffer } from 'node:buffer';
|
|
3
|
-
import type { JpegCompressOptions, PNGLosslessOptions, PngQuantOptions } from '@napi-rs/image';
|
|
4
|
-
import type { Config as SvgoConfig } from 'svgo';
|
|
5
|
-
export type ArrayOrNot<T> = T | T[];
|
|
6
|
-
export interface WebpTransformOptions {
|
|
7
|
-
quality?: number;
|
|
8
|
-
}
|
|
9
|
-
export interface CodecBaseOptions {
|
|
10
|
-
jpeg: JpegCompressOptions;
|
|
11
|
-
png: PngQuantOptions;
|
|
12
|
-
pngLossless: PNGLosslessOptions;
|
|
13
|
-
ico: Record<string, unknown>;
|
|
14
|
-
svg: SvgoConfig;
|
|
15
|
-
}
|
|
16
|
-
export interface BaseCompressOptions<T extends Codecs> {
|
|
17
|
-
use: T;
|
|
18
|
-
test?: ArrayOrNot<RegExp>;
|
|
19
|
-
include?: ArrayOrNot<RegExp>;
|
|
20
|
-
exclude?: ArrayOrNot<RegExp>;
|
|
21
|
-
}
|
|
22
|
-
export type FinalOptionCollection = {
|
|
23
|
-
[K in Codecs]: BaseCompressOptions<K> & CodecBaseOptions[K];
|
|
24
|
-
};
|
|
25
|
-
export type FinalOptions = FinalOptionCollection[Codecs];
|
|
26
|
-
export interface Codec<T extends Codecs> {
|
|
27
|
-
handler: (buf: Buffer, options: CodecBaseOptions[T]) => Promise<Buffer>;
|
|
28
|
-
defaultOptions: Omit<FinalOptionCollection[T], 'use'>;
|
|
29
|
-
}
|
|
30
|
-
export type Codecs = keyof CodecBaseOptions;
|
|
31
|
-
export type OptionCollection = {
|
|
32
|
-
[K in Codecs]: K | FinalOptionCollection[K];
|
|
33
|
-
};
|
|
34
|
-
export type Options = OptionCollection[Codecs];
|