According to the documentation, a custom callback can be passed to the Encore.configureFontRule() and Encore.configureImageRule() functions: https://github.com/symfony/webpack-encore/blob/main/index.js#L1457.
However, when using this callback to specify a custom generator, the filename option of the generator seems to get ignored:
Encore
.configureFontRule(rule => {
rule.test = fontFileExtensionRegex;
rule.generator = {
filename: 'whatever/path/[name][ext]',
};
});
The issue seems to be this default filename option: https://github.com/symfony/webpack-encore/blob/main/lib/WebpackConfig.js#L78.
Using the same example, explicitly setting filename to global.undefined in the regular options seems to fix the issue:
Encore
.configureFontRule(
{
filename: global.undefined,
},
rule => {
rule.test = fontFileExtensionRegex;
rule.generator = {
filename: 'whatever/path/[name][ext]',
};
},
);