Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Cloning a rule #129

Closed
timkelty opened this issue Dec 14, 2018 · 5 comments
Closed

Cloning a rule #129

timkelty opened this issue Dec 14, 2018 · 5 comments

Comments

@timkelty
Copy link

timkelty commented Dec 14, 2018

Seems like I should be able to figure this out but am striking out…
I want to leave an existing rule in place, but "clone" it and add it as a new rule (including direct props like test, resourceQuery, as well as nested maps like uses).

  const baseRule = neutrino.config.module.rules.get('baseRule');

  neutrino.config.module
    .rule('newRule')
    // I want to apply everything from baseRule (e.g. resourceQuery, use/loaders, etc.)?

    // and then manipulate it
    .test(/newTest/);
@timkelty
Copy link
Author

timkelty commented Dec 15, 2018

Closest I've gotten is merging each nested ChainedMap explicitly, but seems like there's got to be better way…

  const baseRule = neutrino.config.module.rules.get('baseRule');
  const newRule = neutrino.config.module.rule('newRule').merge(baseRule.entries());

  baseRule.uses.values().forEach((use) => {
    newRule.use(use.name).merge(use.entries());
  });

   newRule.test(/newTest/);

Any ideas? cc @edmorley @eliperelman

@edmorley
Copy link
Member

It would seem that perhaps the easiest way would be to add support within webpack-chain, if it were seen to be something that people would use? @eliperelman thoughts?

@guanzo
Copy link

guanzo commented Mar 17, 2020

I'd like to know how to clone a plugin, and tweak some options.

@TotooriaHyperion
Copy link

Also want ability to clone the entire config spec, so I can build and publish different bundle for different platform with only one command in our cli tool.(I mean web+rn+microapp+...)

@Shayan-To
Copy link

I need some different processings for a subset of my files, so this would make my life a lot easier.

@edmorley edmorley closed this as completed Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

5 participants