i have some plugin in my Webpack config:
plugins: [
new somePlugin()
]
But i want does not start this plugin when i just run npm run start
, but run if i add some flags, like npm run start --plugin
for example. Is it possible to implement this without dividing the Webpack into different configurations?
You can do this by passing env variables with the webpack command
For Reference read this https://webpack.js.org/api/cli/#environment-options
run => webpack --env.production
Change the module.exports in webpack.config.js as this
Pass any env variable and use it to conditionally push plugins in your config.