Skip to content

Overriding the file name for "configureFontRule" or "configureImageRule" doesn't work when using a generator #1221

Description

@egonolieux

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]',
            };
        },
    );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions