Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,000 changes: 371 additions & 629 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@
"cross-env": "^7.0.2",
"del": "^6.0.0",
"del-cli": "^3.0.1",
"eslint": "^7.16.0",
"eslint": "^7.17.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-import": "^2.22.1",
"file-loader": "^6.2.0",
"husky": "^4.3.6",
"husky": "^4.3.7",
"jest": "^26.6.3",
"lint-staged": "^10.5.1",
"memfs": "^3.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"standard-version": "^9.0.0",
"webpack": "^5.11.0",
"webpack-stats-plugin": "^1.0.2",
"standard-version": "^9.1.0",
"webpack": "^5.12.3",
"webpack-stats-plugin": "^1.0.3",
"workbox-webpack-plugin": "^6.0.2"
},
"keywords": [
Expand Down
27 changes: 20 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import path from "path";
import crypto from "crypto";

import { validate } from "schema-utils";
import serialize from "serialize-javascript";
Expand Down Expand Up @@ -126,15 +127,27 @@ class CompressionPlugin {
let relatedName;

if (typeof this.options.algorithm === "function") {
let filenameForRelatedName = this.options.filename;

const index = filenameForRelatedName.indexOf("?");
if (typeof this.options.filename === "function") {
relatedName = `compression-function-${crypto
.createHash("md5")
.update(serialize(this.options.filename))
.digest("hex")}`;
} else {
let filenameForRelatedName = this.options.filename;

const index = filenameForRelatedName.indexOf("?");

if (index >= 0) {
filenameForRelatedName = filenameForRelatedName.substr(
0,
index
);
}

if (index >= 0) {
filenameForRelatedName = filenameForRelatedName.substr(0, index);
relatedName = `${path
.extname(filenameForRelatedName)
.slice(1)}ed`;
}

relatedName = `${path.extname(filenameForRelatedName).slice(1)}ed`;
} else if (this.options.algorithm === "gzip") {
relatedName = "gzipped";
} else {
Expand Down
Loading