Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gitwithravish's avatar

Webpack : Single config file VS Multiple config files

I have seen people making multiple webpack files to organise configuration.

webpack.common.js
webpack.dev.js
webpack.prod.js

Where as some tutorials shows a single webpack.config.js. webpack.config.js

module.exports = {
	//config
}

if(process.env.NODE_ENV === 'production'){
     module.exports.plugins = (module.exports.plugins || []).concat([
      	    //additional plugins
      }),

	// more config
}

The first approach is organised but sometime if you decide to add a plugin for development and production with maybe just one different settings, then you have to put both plugins in both files which leads to some amount of duplication. Whereas second approach is less organised and may seem complex then the first approach.

Can anyone experienced with webpack tell me which approach is maintainable for a large project ?

0 likes
0 replies

Please or to participate in this conversation.