HookWebpackError: filenameForRelatedName.indexOf is not a function
gqgs opened this issue · 5 comments
- compression-webpack-plugin Version: 7.1.1
Expected Behavior
The plugin to compress data as expected.
Actual Behavior
webpack crashes wtih a HookWebpackError after the plugin tries to access the indexOf
of a function.
HookWebpackError: filenameForRelatedName.indexOf is not a function
Code
// webpack.config.js
const zopfli = require("@gfx/zopfli");
module.exports = {
plugins: [
new CompressionPlugin({
filename(pathData) {
// other things here...
return "[path][name].gz";
},
algorithm(input, compressionOptions, callback) {
return zopfli.gzip(input, compressionOptions, callback);
},
}),
],
};
How Do We Reproduce?
Apparently it happens if algorithm
and filename
properties are both defined as functions.
I could be missing something but it seems the case where filename
is a function is being ignored in the section bellow.
compression-webpack-plugin/src/index.js
Lines 128 to 131 in 44c16e2
Yep, bug
Just interesting - why do you use it as function? zopfli
supported by Node.js, using [path][name].gz
doesn't have sense because it is static
@alexander-akait I'm using a different algorithm
and filename
functions. I just used that from the docs since it'd be easier to reproduce/understand.
Yep, I will fix it tomorrow, thanks for the issue
@alexander-akait Thank you.