Skip to content

Commit

Permalink
fix: webpack compilations fail when using filesystem cache, #458
Browse files Browse the repository at this point in the history
  • Loading branch information
webdiscus committed Dec 16, 2024
1 parent 8eb07f8 commit c213a30
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [4.1.2](https://github.com/webpack-contrib/image-minimizer-webpack-plugin/compare/v4.1.1...v4.1.2) (2024-12-16)


### Bug Fixes

* webpack compilations fail when using filesystem cache [#458](#458)

### [4.1.1](https://github.com/webpack-contrib/image-minimizer-webpack-plugin/compare/v4.1.0...v4.1.1) (2024-11-19)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "image-minimizer-webpack-plugin",
"version": "4.1.1",
"version": "4.1.2",
"description": "Webpack loader and plugin to optimize (compress) images using imagemin",
"license": "MIT",
"repository": "webpack-contrib/image-minimizer-webpack-plugin",
Expand Down
8 changes: 5 additions & 3 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ async function loader(content) {
}

let isAbsolute = isAbsoluteURL(this.resourcePath);
const isData = this.resourcePath.startsWith("DATA:");
const shouldMakeRelative = !isData && isAbsolute;

const filename = isAbsolute
? this.resourcePath
: path.relative(this.rootContext, this.resourcePath);
const filename = shouldMakeRelative
? path.relative(this.rootContext, this.resourcePath)
: this.resourcePath;

const minifyOptions =
/** @type {import("./index").InternalWorkerOptions<T>} */ ({
Expand Down
6 changes: 3 additions & 3 deletions test/ImageminPlugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ describe("imagemin plugin", () => {
const stringStats = stats.toString({ relatedAssets: true });

expect(stringStats).toMatch(
/asset loader-test.webp.+\[from: .+loader-test.png\] \[generated\]/,
/asset loader-test.webp.+\[from: .*loader-test.png\] \[generated\]/,
);
});

Expand Down Expand Up @@ -1386,7 +1386,7 @@ describe("imagemin plugin", () => {
expect(warnings).toHaveLength(0);
expect(errors).toHaveLength(1);
expect(errors[0].message).toMatch(
/Multiple values for the 'encodeOptions' option is not supported for '.+loader-test.png', specify only one codec for the generator/,
/Multiple values for the 'encodeOptions' option is not supported for '.*loader-test.png', specify only one codec for the generator/,
);
});

Expand Down Expand Up @@ -1771,7 +1771,7 @@ describe("imagemin plugin", () => {
expect(warnings).toHaveLength(0);
expect(errors).toHaveLength(1);
expect(errors[0].message).toMatch(
/Error with '.+loader-test.txt': Input file has an unsupported format/g,
/Error with '.*loader-test.txt': Input file has an unsupported format/g,
);
});

Expand Down

0 comments on commit c213a30

Please sign in to comment.