@rsbuild/plugin-image-compress 0.3.0 → 0.3.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 +1 -1
- package/dist/index.js +7 -1
- package/dist/index.mjs +13 -5
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name in all)
|
|
10
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -26,6 +27,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
27
|
mod
|
|
27
28
|
));
|
|
28
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __publicField = (obj, key, value) => {
|
|
31
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
32
|
+
return value;
|
|
33
|
+
};
|
|
29
34
|
|
|
30
35
|
// src/index.ts
|
|
31
36
|
var src_exports = {};
|
|
@@ -97,7 +102,8 @@ var codecs_default = codecs;
|
|
|
97
102
|
var IMAGE_MINIMIZER_PLUGIN_NAME = "@rsbuild/plugin-image-compress/minimizer";
|
|
98
103
|
var ImageMinimizerPlugin = class {
|
|
99
104
|
constructor(options) {
|
|
100
|
-
this
|
|
105
|
+
__publicField(this, "name", IMAGE_MINIMIZER_PLUGIN_NAME);
|
|
106
|
+
__publicField(this, "options");
|
|
101
107
|
this.options = options;
|
|
102
108
|
}
|
|
103
109
|
async optimize(compiler, compilation, assets) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
// ../../node_modules/.pnpm/@modern-js+module-tools@2.45.0_typescript@5.3.2/node_modules/@modern-js/module-tools/shims/esm.js
|
|
2
9
|
import { fileURLToPath } from "url";
|
|
3
10
|
import path from "path";
|
|
@@ -10,10 +17,10 @@ global.require = createRequire(import.meta.url);
|
|
|
10
17
|
import assert2 from "assert";
|
|
11
18
|
|
|
12
19
|
// src/minimizer.ts
|
|
13
|
-
import { Buffer as
|
|
20
|
+
import { Buffer as Buffer3 } from "buffer";
|
|
14
21
|
|
|
15
22
|
// src/shared/codecs.ts
|
|
16
|
-
import { Buffer } from "buffer";
|
|
23
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
17
24
|
import {
|
|
18
25
|
compressJpeg,
|
|
19
26
|
losslessCompressPng,
|
|
@@ -56,7 +63,7 @@ var icoCodec = {
|
|
|
56
63
|
var svgCodec = {
|
|
57
64
|
async handler(buf, options) {
|
|
58
65
|
const result = svgo.optimize(buf.toString(), options);
|
|
59
|
-
return
|
|
66
|
+
return Buffer2.from(result.data);
|
|
60
67
|
},
|
|
61
68
|
defaultOptions: {
|
|
62
69
|
test: /\.svg$/
|
|
@@ -75,7 +82,8 @@ var codecs_default = codecs;
|
|
|
75
82
|
var IMAGE_MINIMIZER_PLUGIN_NAME = "@rsbuild/plugin-image-compress/minimizer";
|
|
76
83
|
var ImageMinimizerPlugin = class {
|
|
77
84
|
constructor(options) {
|
|
78
|
-
this
|
|
85
|
+
__publicField(this, "name", IMAGE_MINIMIZER_PLUGIN_NAME);
|
|
86
|
+
__publicField(this, "options");
|
|
79
87
|
this.options = options;
|
|
80
88
|
}
|
|
81
89
|
async optimize(compiler, compilation, assets) {
|
|
@@ -112,7 +120,7 @@ ${cause.message}` : cause.message;
|
|
|
112
120
|
try {
|
|
113
121
|
if (!result) {
|
|
114
122
|
const input = inputSource.source();
|
|
115
|
-
const buf = await codec.handler(
|
|
123
|
+
const buf = await codec.handler(Buffer3.from(input), opts);
|
|
116
124
|
result = { source: new RawSource(buf) };
|
|
117
125
|
await cacheItem.storePromise(result);
|
|
118
126
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-image-compress",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Image compress plugin for Rsbuild",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"repository": {
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@napi-rs/image": "^1.7.0",
|
|
27
27
|
"svgo": "^3.2.0",
|
|
28
|
-
"@rsbuild/shared": "0.3.
|
|
28
|
+
"@rsbuild/shared": "0.3.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "16.x",
|
|
32
32
|
"typescript": "^5.3.0",
|
|
33
33
|
"webpack": "^5.89.0",
|
|
34
|
-
"@rsbuild/core": "0.3.
|
|
35
|
-
"@
|
|
36
|
-
"@rsbuild/webpack": "0.3.
|
|
34
|
+
"@rsbuild/core": "0.3.2",
|
|
35
|
+
"@scripts/test-helper": "1.0.0",
|
|
36
|
+
"@rsbuild/webpack": "0.3.2"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public",
|