function* getLoaders(rule) {
    if (rule.loader) {
        // @ts-ignore
        yield { loader: rule.loader, options: rule.options || undefined };
    }

    /** @type {{ loader: string, options?: Record<string, any>}[]} */
    // @ts-ignore
    const loaders = rule.use || [];

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

@param {import('webpack').RuleSetRule} rule
@returns {Generator<{ loader: string, options?: Record<string, any>}>}