Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Merge Webpack configs #2525

Closed
emirotin opened this issue Jun 13, 2017 · 11 comments
Closed

Proposal: Merge Webpack configs #2525

emirotin opened this issue Jun 13, 2017 · 11 comments

Comments

@emirotin
Copy link

emirotin commented Jun 13, 2017

Sorry if this was discussed before, I tried searching the issues and didn't find any match.
There are not so many differences between the webpack configs (dev / prod) and I have the working example (https://gist.github.com/emirotin/4ee74e426b20055e418a0101d754f8be) where they're merged into a single factory.
Then the entry configs just look like:

const getConfig = require('./webpack-config');
module.exports = getConfig(false);

If this is interesting I can send a PR.

Why is it useful?
On a regular basis, I have to eject because I need TS support. This means at least adding a loader (same for dev and prod) and updating the list of extensions.
Quite often I also want to play a bit with some plugins configuration and then need to replicate these changes in prod config.

@ulrikstrid
Copy link
Contributor

If you just want to add typescript you could use https://github.com/wmonk/create-react-app-typescript

@emirotin
Copy link
Author

TS is just an example, obv it can be CSS modules, or other modifications that apply to both dev and prod

@gaearon
Copy link
Contributor

gaearon commented Jun 22, 2017

I am generally supporting of migrating to Webpack 2's env feature for this.

@emirotin
Copy link
Author

Do you mean https://webpack.js.org/guides/environment-variables/ (which is basically my current approach, but with NODE_ENV detection instead of separate entry files) or something
like https://github.com/survivejs/webpack-merge?

@gaearon
Copy link
Contributor

gaearon commented Jun 23, 2017

I mean this: https://webpack.js.org/guides/migrating/#using-custom-arguments-in-cli-and-configuration. Although now that I think of it, it won't really help because we don't use the CLI. But maybe we can use the same format: one webpack.config.js that exports a function taking env.

@emirotin
Copy link
Author

emirotin commented Jun 26, 2017 via email

@gaearon
Copy link
Contributor

gaearon commented Jun 26, 2017

Yep, same thing.

@emirotin
Copy link
Author

emirotin commented Jun 26, 2017 via email

@vinhlh
Copy link

vinhlh commented Jul 25, 2017

Love to see this. We don't want to maintain ejected things (really hard), but a flexible way to add some customize configurations.

@gaearon
Copy link
Contributor

gaearon commented Jan 8, 2018

@vinhlh This is not what this issue was about.

@gaearon
Copy link
Contributor

gaearon commented Jan 8, 2018

I'll close as stale.

@gaearon gaearon closed this as completed Jan 8, 2018
@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants