Dynamic synchronous import is not possible using ES2015 modules. Dynamically, you can import material with asynchronous import through import() .
Why don't you just import it and apply it conditionally?
import StatsPlugin from 'webpack-stats-plugin'; ... if (process.env.NODE_ENV === 'production') { config.plugins.push(new Statsplugin()) }
source share