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

Webpack configuration more DRY between production and dev #348

Closed
wants to merge 1 commit into from
Closed

Webpack configuration more DRY between production and dev #348

wants to merge 1 commit into from

Conversation

Spittal
Copy link
Contributor

@Spittal Spittal commented Feb 22, 2016

Made a more generic webpack.make.config.js file that includes all the instructions on how to build the project with both production and development. The webpack.config.js and the webpack.prod.config.js files are now requiring the new make file and passing in some arguments (in this case just an option called PRODUCTION). Based on these arguments the make file will change how it returns the config object.

Using this method you don't need to edit two files when you add a loader, or change a plugin. They are using the same configuration file and that makes it much more DRY!

Made a more generic `webpack.make.config.js` file that includes all the instructions on how to build the project with both production and development. The `webpack.config.js` and the `webpack.prod.config.js` files are not requiring the new make file and passing in some arguments (in this case just an option called `PRODUCTION`). Based on these arguments the make file will change how it returns the config object.

using this method you don't need to edit two files when you add a loader, or change a plugin. They are using the same configuration file and that makes it much more DRY!
@PatrickJS
Copy link
Owner

the goal was to make webpack approachable and easier to reason about what's going on rather than dry. this pull-request introduces too much magic for developers starting out with webpack so I cannot merge it even though it's better for developers who already know webpack

@PatrickJS PatrickJS closed this Feb 26, 2016
@samvloeberghs
Copy link
Contributor

I back this comment from @gdi2290 and wanted to make the same comment before.

Although I like the idea of configuration and the DRY principle, separating the config files gives you more flexibility and readability ( depending on the environment), with the little compromise of having to repeat yourself. Putting too much logic in one file will also bloat it a lot ( especially when you're extending this basic setup )

@Spittal
Copy link
Contributor Author

Spittal commented Feb 26, 2016

Totally fair!

There should however be some documentation either in the wiki or README that mentions you need to edit both configurations if you're adding loaders like scss or postcss.

@PatrickJS
Copy link
Owner

@Spittal great idea! can you edit this page https://github.com/AngularClass/angular2-webpack-starter/wiki/How-to-DRY-up-your-webpack-config I can also change the title or anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants