webpack-chain icon indicating copy to clipboard operation
webpack-chain copied to clipboard

Create from existing webpack config object

Open joeldenning opened this issue 4 years ago • 4 comments

I would love to be able to construct a webpack chain instance from an existing webpack config object. I've searched the documentation and code and it doesn't seem to be possible as far as I can tell. My main use cases are to take a shared webpack config object and modify it. The shared webpack config object is published to npm as module.exports = {...}, not as a webpack chain instance.

If you're open to this, I am interested in exploring what an implementation would look like for this, and even put together a PR for it.

joeldenning avatar Jul 20 '20 21:07 joeldenning

I have the same needs.

lijialiang avatar Sep 23 '20 07:09 lijialiang

This could also be a great way to allow for cloning webpack-chain config, since according to another issue is not yet possible.

kacpak avatar Nov 23 '20 15:11 kacpak

Bump

rmarmitt avatar Jun 19 '22 23:06 rmarmitt

One of the issues here, is that the webpack-chain's representation of a webpack-config is richer than the original webpack-config. That is, there is additional metadata that names parts of the config, allowing for them to be referenced/manipulated more easily.

As such, if one tried to implement this, you'd have to pick random names/identifiers for the parts of the config that weren't set via webpack-chain (eg ascending numbers or something), making it hard to manipulate them without having to hardcode numerical indices, thereby defeating much of the purpose of webpack-chain.

At which point, why even try and use webpack-chain, and why not just manipulate the original webpack-config directly?

edmorley avatar Jun 20 '22 08:06 edmorley