score:2

i solved this with the following code:

(iconname) => {
  require.ensure([], require => {
  require(`../../images/icons/${iconname}.svg`)
  })
}

class mycomponent extends component {
  state = {
    categoryicon: require(`../../images/icons/${this.props.icon}.svg`)
  };

reading the webpack docs on code splitting more carefully helped.


Related Query

More Query from same tag