Static GitHub Issues

[1288] Improve nuxt.config.js interface

prev: Cannot transition child routes
next: PWA

Hi! Nuxt.js has been an amazing tool for me, serving tons of config up-front while allowing to customize stuff the way I need. However, what's been an issue for me is the API to extend the config in nuxt.config.js file. The main issue is that user has to modify existing config object.

While it's arguable that it may not be the best practice and the code looks more imperative rather than declarative, the big downside for me is that I can't use the power of webpack-merge to extend the default config with custom one (the reason being that reassigning function arguments has no effect). To give you an example, backpack has very similar config extension strategy, but instead of modifying the existing config you just have to return a new one, then extending the webpack config becomes as easy as this:

webpack: (defaultConfig, options, webpack) => {
  return merge(defaultConfig, customConfig)
}

I propose that the API for extending config is changed, so that extend and extendRoutes methods have to return the new config object instead of modifying the existing one.

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This feature request is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1140">#c1140</a>)</em></sub></div>