score:1

i think this is not a webpack issue, it's app.js file.

in my case, there was a 'let' declaration issue. it was working in a dev environment but wasn't on a production build. basically, in the build process, we need to take special care of const/let/function declarations order and scope, so that after the build, declaration reference will get actual declarations.

my case was:

const products = products.map(group => {
   let resultbutton = '';
   if (!group.product[0].soldout) {
    let price = 0;
    price += group.product[0].amount.amount;
    if (group.product[0].fees) {
     for (let i = 0; i < group.product[0].fees.length; i += 1) {
      price += group.product[0].fees[i].amount;
      }
     }

     // here was my wrong declaration
     // i corrected by declaring outside of if (!group.product[0].soldout) 
     // below let resultbutton = '';
     // & it works for me after build
     let benefits = <li>no benefits defined</li>;

     if (
     group.product[0].properties&&
        group.product[0].properties.length > 0
      ) {

        _.map(group.product[0].properties.property, property => {
          if (property.code === 51) {
            const benefitsarray = property.content.split('\n');
            benefits = benefitsarray.map(item => {
              const st = item.replace(/ +/g, '');
              return <li key={st}>{item}</li>;
          });
          }
        });
      }
      
      resultbutton = (
        <div>
          <h4>
          <ul>{benefits}</ul>
        </div>
      );
    } else {
      resultbutton = (
        <div>
          <soldout>
        </div>
      );
    }
    return resultbutton;
  });

hope you'll get the answer.


Related Query

More Query from same tag