Message Boards

Liferay 7.3: MVC Portlet with React - How to run React in Production Mode?

Erik Strauß, modified 3 Years ago.

Liferay 7.3: MVC Portlet with React - How to run React in Production Mode?

New Member Posts: 10 Join Date: 5/6/18 Recent Posts
Hello together,

I have an MVC portlet with React JS in the frontend. Everything is working fine, but my jar file is always delivered with React in developer mode. How can I change this? Where do I set the ENV_VARIBALE?  

I have a package.json and a .bablerc file. The whole thing is built with the liferay-npm-bundler.

[code]{
   "dependencies": {
      "react": "^16.13.1",
      "react-dom": "^16.13.1"
   },
   "devDependencies": {
      "@babel/cli": "^7.11.6",
      "@babel/core": "^7.11.6",
      "@babel/plugin-proposal-class-properties": "^7.10.4",
      "@babel/plugin-proposal-object-rest-spread": "^7.11.0",
      "@babel/preset-env": "^7.11.5",
      "@babel/preset-react": "^7.10.4",
      "liferay-npm-bundler": "^2.19.1"
   },
   "main": "lib/MyJsFile.js",
   "name": "my-js-portlet",
   "scripts": {
      "build": "babel --source-maps -d build/resources/main/META-INF/resources src/main/resources/META-INF/resources && liferay-npm-bundler"
   },
   "version": "1.0.0"
}
thumbnail
Danilo Buzar, modified 3 Years ago.

RE: Liferay 7.3: MVC Portlet with React - How to run React in Production Mo

New Member Posts: 3 Join Date: 7/13/17 Recent Posts
Hi Erik,You could try adding NODE_ENV=production in build script, like:
"scripts": {
  "build": "NODE_ENV=production babel --source-maps -d build/resources/main/META-INF/resources src/main/resources/META-INF/resources && liferay-npm-bundler"
},
Erik Strauß, modified 3 Years ago.

RE: Liferay 7.3: MVC Portlet with React - How to run React in Production Mo

New Member Posts: 10 Join Date: 5/6/18 Recent Posts
I have already tried - unfortunately without success.
Does anyone else have an idea?
Erik Strauß, modified 3 Years ago.

RE: Liferay 7.3: MVC Portlet with React - How to run React in Production Mo

New Member Posts: 10 Join Date: 5/6/18 Recent Posts
Nobody has an idea how I can change that?
The liferay-npm-bundler must be able to do that ...