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

Make Webpack Upgradable and DRY #453

Merged
merged 10 commits into from
Mar 28, 2016
Merged

Make Webpack Upgradable and DRY #453

merged 10 commits into from
Mar 28, 2016

Conversation

Spittal
Copy link
Contributor

@Spittal Spittal commented Mar 21, 2016

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    The webpack configuration has been changed so that components of the configuration that is shared between production and development are now in one file. It makes the files more cohesive and easier to update.

I've tried introducing this before, but was rejected on grounds of complexity. I would like to argue that this configuration is yes slightly more complex (not anymore complex than other parts of this starter pack) but makes it much easier to to merge in changes from this repo into existing projects. Not only does it allow you put your custom loaders in a single file, but also the "config" object having the ability to be passed around means that you can merge changes from this repo much easier without breaking some "application specific" changes.

  • What is the current behavior? (You can also link to an open issue here)
    There is a lots of duplicate code in the webpack configurations.
  • What is the new behavior (if this is a feature change)?
    Made the webpack conmfiguration more dry, and more scalable.
  • Other information:
    I've been trying to stay up to date with the latest polyfills, and beta versions of Angular while developing an application, It's important to me that I am able to quickly apply changes made in this repo to my own applications. This PR would make that process much faster for me.

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!
# Conflicts:
#	webpack.config.js
#	webpack.prod.config.js
@Spittal Spittal changed the title Make webpack more upgradable and Dry Make Webpack Upgradable and DRY Mar 21, 2016
@PatrickJS
Copy link
Owner

this is fine having a common/base/default config but only if we create a new copy

var defaultConfig = require('webpack.defaults.js');

module.exports = webpackMerge(defaultConfig, {
  devtool: 'eval'
});

that's more familiar to new webpack devs

@mbcooper
Copy link

+1

@Spittal
Copy link
Contributor Author

Spittal commented Mar 24, 2016

Hey @gdi2290 I was able to refactor using webpack merge. Tested with npm run server npm run build:prod and npm run build:dev. Seems to be working great.

@fishfillet
Copy link

+1

@aegyed91
Copy link

@Spittal @gdi2290 why not Object.assign? im not a webpack expert, but the config is just an object

Object.assign({}, obj1, obj2) will create a new object

EDIT: anyways, wouldn't it be easier to just keep everything in one file like this? Also, this is 0% redundant.

@PatrickJS PatrickJS merged commit 19f7b29 into PatrickJS:master Mar 28, 2016
@PatrickJS
Copy link
Owner

thanks!

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.

5 participants