@rsbuild/plugin-image-compress 0.3.6 → 0.3.8
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.js +10 -10
- package/dist/index.mjs +2 -2
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -39,13 +39,13 @@ __export(src_exports, {
|
|
|
39
39
|
pluginImageCompress: () => pluginImageCompress
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(src_exports);
|
|
42
|
-
var
|
|
42
|
+
var import_node_assert2 = __toESM(require("assert"));
|
|
43
43
|
|
|
44
44
|
// src/minimizer.ts
|
|
45
|
-
var
|
|
45
|
+
var import_node_buffer2 = require("buffer");
|
|
46
46
|
|
|
47
47
|
// src/shared/codecs.ts
|
|
48
|
-
var
|
|
48
|
+
var import_node_buffer = require("buffer");
|
|
49
49
|
var import_image = require("@napi-rs/image");
|
|
50
50
|
var import_svgo = __toESM(require("svgo"));
|
|
51
51
|
var jpegCodec = {
|
|
@@ -83,7 +83,7 @@ var icoCodec = {
|
|
|
83
83
|
var svgCodec = {
|
|
84
84
|
async handler(buf, options) {
|
|
85
85
|
const result = import_svgo.default.optimize(buf.toString(), options);
|
|
86
|
-
return
|
|
86
|
+
return import_node_buffer.Buffer.from(result.data);
|
|
87
87
|
},
|
|
88
88
|
defaultOptions: {
|
|
89
89
|
test: /\.svg$/
|
|
@@ -140,7 +140,7 @@ ${cause.message}` : cause.message;
|
|
|
140
140
|
try {
|
|
141
141
|
if (!result) {
|
|
142
142
|
const input = inputSource.source();
|
|
143
|
-
const buf = await codec.handler(
|
|
143
|
+
const buf = await codec.handler(import_node_buffer2.Buffer.from(input), opts);
|
|
144
144
|
result = { source: new RawSource(buf) };
|
|
145
145
|
await cacheItem.storePromise(result);
|
|
146
146
|
}
|
|
@@ -174,12 +174,12 @@ ${cause.message}` : cause.message;
|
|
|
174
174
|
};
|
|
175
175
|
|
|
176
176
|
// src/shared/utils.ts
|
|
177
|
-
var
|
|
177
|
+
var import_node_assert = __toESM(require("assert"));
|
|
178
178
|
var withDefaultOptions = (opt) => {
|
|
179
179
|
const options = typeof opt === "string" ? { use: opt } : opt;
|
|
180
180
|
const { defaultOptions } = codecs_default[options.use];
|
|
181
181
|
const ret = { ...defaultOptions, ...options };
|
|
182
|
-
(0,
|
|
182
|
+
(0, import_node_assert.default)("test" in ret);
|
|
183
183
|
return ret;
|
|
184
184
|
};
|
|
185
185
|
|
|
@@ -192,7 +192,7 @@ var castOptions = (args) => {
|
|
|
192
192
|
}
|
|
193
193
|
const ret = [];
|
|
194
194
|
for (const arg of args) {
|
|
195
|
-
(0,
|
|
195
|
+
(0, import_node_assert2.default)(!Array.isArray(arg));
|
|
196
196
|
ret.push(arg);
|
|
197
197
|
}
|
|
198
198
|
return ret;
|
|
@@ -206,8 +206,8 @@ var pluginImageCompress = (...args) => ({
|
|
|
206
206
|
name: "rsbuild:image-compress",
|
|
207
207
|
setup(api) {
|
|
208
208
|
const opts = normalizeOptions(castOptions(args));
|
|
209
|
-
api.modifyBundlerChain((chain, {
|
|
210
|
-
if (
|
|
209
|
+
api.modifyBundlerChain((chain, { isDev }) => {
|
|
210
|
+
if (isDev) {
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
213
|
chain.optimization.minimize(true);
|
package/dist/index.mjs
CHANGED
|
@@ -185,8 +185,8 @@ var pluginImageCompress = (...args) => ({
|
|
|
185
185
|
name: "rsbuild:image-compress",
|
|
186
186
|
setup(api) {
|
|
187
187
|
const opts = normalizeOptions(castOptions(args));
|
|
188
|
-
api.modifyBundlerChain((chain, {
|
|
189
|
-
if (
|
|
188
|
+
api.modifyBundlerChain((chain, { isDev }) => {
|
|
189
|
+
if (isDev) {
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
chain.optimization.minimize(true);
|
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.8",
|
|
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.7.0",
|
|
27
27
|
"svgo": "^3.2.0",
|
|
28
|
-
"@rsbuild/shared": "0.3.
|
|
28
|
+
"@rsbuild/shared": "0.3.8"
|
|
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
|
-
"@scripts/test-helper": "0.3.
|
|
36
|
-
"@rsbuild/webpack": "0.3.
|
|
34
|
+
"@rsbuild/core": "0.3.8",
|
|
35
|
+
"@scripts/test-helper": "0.3.8",
|
|
36
|
+
"@rsbuild/webpack": "0.3.8"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@rsbuild/core": "^0.3.
|
|
39
|
+
"@rsbuild/core": "^0.3.8"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public",
|