Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to get a production build with Liferay for react? Liferay 7.2
Hi,I have been searching on the internet for a few hours, but i cannot find anything about it. I just have this, which for development is fine, but I need to deploy my portlets as a production build as well, I always use:
What to do? Any ideas?
npm run build OR npm run deploybut that just keeps building a normal .jar file in dev mode, and I need one for production. If I check my portlets with react developer tools in Chrome, I have this message:

What to do? Any ideas?
I am not really a react guy, but check the package.json file.
You usually need to have an extra build target for that, and usually implement it by adding some parameters to the npm scripts, eg. in our case with webpack it looks this way: (npm run production)
I hope, there is already a fitting target in in the package.json. If not, you could try to set the environment variable as we do it. But the build has to support that. The script has to check the mode and use e.g. TerserPlugin or something like that in that case.
You usually need to have an extra build target for that, and usually implement it by adding some parameters to the npm scripts, eg. in our case with webpack it looks this way: (npm run production)
"production": "cross-env NODE_ENV=production ./node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config webpack/config/webpack.prod.js",I hope, there is already a fitting target in in the package.json. If not, you could try to set the environment variable as we do it. But the build has to support that. The script has to check the mode and use e.g. TerserPlugin or something like that in that case.