@rsbuild/plugin-image-compress 0.2.15 → 0.2.17

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 CHANGED
@@ -94,19 +94,19 @@ var codecs = {
94
94
  var codecs_default = codecs;
95
95
 
96
96
  // src/minimizer.ts
97
- var MODERN_JS_IMAGE_MINIMIZER_PLUGIN_NAME = "@rsbuild/plugin-image-compress/minimizer";
98
- var ModernJsImageMinimizerPlugin = class {
97
+ var IMAGE_MINIMIZER_PLUGIN_NAME = "@rsbuild/plugin-image-compress/minimizer";
98
+ var ImageMinimizerPlugin = class {
99
99
  constructor(options) {
100
- this.name = MODERN_JS_IMAGE_MINIMIZER_PLUGIN_NAME;
100
+ this.name = IMAGE_MINIMIZER_PLUGIN_NAME;
101
101
  this.options = options;
102
102
  }
103
103
  async optimize(compiler, compilation, assets) {
104
- const cache = compilation.getCache(MODERN_JS_IMAGE_MINIMIZER_PLUGIN_NAME);
104
+ const cache = compilation.getCache(IMAGE_MINIMIZER_PLUGIN_NAME);
105
105
  const { RawSource } = compiler.webpack.sources;
106
106
  const { matchObject } = compiler.webpack.ModuleFilenameHelpers;
107
107
  const buildError = (error, file, context) => {
108
108
  const cause = error instanceof Error ? error : new Error();
109
- const message = file && context ? `"${file}" in "${context}" from Modern.js Image Minimizer:
109
+ const message = file && context ? `"${file}" in "${context}" from Image Minimizer:
110
110
  ${cause.message}` : cause.message;
111
111
  const ret = new compiler.webpack.WebpackError(message);
112
112
  error instanceof Error && (ret.error = error);
@@ -198,13 +198,13 @@ var pluginImageCompress = (...args) => ({
198
198
  name: "rsbuild:image-compress",
199
199
  setup(api) {
200
200
  const opts = normalizeOptions(castOptions(args));
201
- api.modifyBundlerChain((chain, { env }) => {
202
- if (env !== "production") {
201
+ api.modifyBundlerChain((chain, { isProd }) => {
202
+ if (!isProd) {
203
203
  return;
204
204
  }
205
205
  chain.optimization.minimize(true);
206
206
  for (const opt of opts) {
207
- chain.optimization.minimizer(`image-compress-${opt.use}`).use(ModernJsImageMinimizerPlugin, [opt]);
207
+ chain.optimization.minimizer(`image-compress-${opt.use}`).use(ImageMinimizerPlugin, [opt]);
208
208
  }
209
209
  });
210
210
  }
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.44.0_typescript@5.3.2/node_modules/@modern-js/module-tools/shims/esm.js
1
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.45.0_typescript@5.3.2/node_modules/@modern-js/module-tools/shims/esm.js
2
2
  import { fileURLToPath } from "url";
3
3
  import path from "path";
4
4
 
@@ -72,19 +72,19 @@ var codecs = {
72
72
  var codecs_default = codecs;
73
73
 
74
74
  // src/minimizer.ts
75
- var MODERN_JS_IMAGE_MINIMIZER_PLUGIN_NAME = "@rsbuild/plugin-image-compress/minimizer";
76
- var ModernJsImageMinimizerPlugin = class {
75
+ var IMAGE_MINIMIZER_PLUGIN_NAME = "@rsbuild/plugin-image-compress/minimizer";
76
+ var ImageMinimizerPlugin = class {
77
77
  constructor(options) {
78
- this.name = MODERN_JS_IMAGE_MINIMIZER_PLUGIN_NAME;
78
+ this.name = IMAGE_MINIMIZER_PLUGIN_NAME;
79
79
  this.options = options;
80
80
  }
81
81
  async optimize(compiler, compilation, assets) {
82
- const cache = compilation.getCache(MODERN_JS_IMAGE_MINIMIZER_PLUGIN_NAME);
82
+ const cache = compilation.getCache(IMAGE_MINIMIZER_PLUGIN_NAME);
83
83
  const { RawSource } = compiler.webpack.sources;
84
84
  const { matchObject } = compiler.webpack.ModuleFilenameHelpers;
85
85
  const buildError = (error, file, context) => {
86
86
  const cause = error instanceof Error ? error : new Error();
87
- const message = file && context ? `"${file}" in "${context}" from Modern.js Image Minimizer:
87
+ const message = file && context ? `"${file}" in "${context}" from Image Minimizer:
88
88
  ${cause.message}` : cause.message;
89
89
  const ret = new compiler.webpack.WebpackError(message);
90
90
  error instanceof Error && (ret.error = error);
@@ -176,13 +176,13 @@ var pluginImageCompress = (...args) => ({
176
176
  name: "rsbuild:image-compress",
177
177
  setup(api) {
178
178
  const opts = normalizeOptions(castOptions(args));
179
- api.modifyBundlerChain((chain, { env }) => {
180
- if (env !== "production") {
179
+ api.modifyBundlerChain((chain, { isProd }) => {
180
+ if (!isProd) {
181
181
  return;
182
182
  }
183
183
  chain.optimization.minimize(true);
184
184
  for (const opt of opts) {
185
- chain.optimization.minimizer(`image-compress-${opt.use}`).use(ModernJsImageMinimizerPlugin, [opt]);
185
+ chain.optimization.minimizer(`image-compress-${opt.use}`).use(ImageMinimizerPlugin, [opt]);
186
186
  }
187
187
  });
188
188
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-image-compress",
3
- "version": "0.2.15",
3
+ "version": "0.2.17",
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.0.2",
28
- "@rsbuild/shared": "0.2.15"
28
+ "@rsbuild/shared": "0.2.17"
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.2.15",
35
- "@rsbuild/webpack": "0.2.15",
36
- "@rsbuild/test-helper": "0.2.15"
34
+ "@rsbuild/test-helper": "0.2.17",
35
+ "@rsbuild/core": "0.2.17",
36
+ "@rsbuild/webpack": "0.2.17"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public",