function* getRules(config, test) {
    /** @type {import('webpack').RuleSetRule[]} */
    // @ts-ignore: Configs built by mix always have a rules array
    const rules = (config.module && config.module.rules) || [];

    for (const rule of toRules(rules)) {
        if (test && !test(rule)) {
            continue;
        }

        yield rule;
    }
}
Check that a matching webpack rule can be found

@param {import("webpack").Configuration} config
@param {(rule: import('webpack').RuleSetRule) => boolean} [test]
@returns {Generator<import("webpack").RuleSetRule>}