liferay-npm-bundler/liferay-js-toolkit: Use .env filesliferay-npm-bundler/liferay-js-toolkit: Use .env fileshttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1187086572024-03-28T13:03:36Z2024-03-28T13:03:36ZRE: liferay-npm-bundler/liferay-js-toolkit: Use .env filesIván Zaera Avellónhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1197565852020-08-13T10:08:38Z2020-08-13T10:08:38ZAFAIK you just need to play with the NODE_ENV environment variable. So you could run 'NODE_ENV=production npm run build' , for example.Iván Zaera Avellón2020-08-13T10:08:38ZRE: liferay-npm-bundler/liferay-js-toolkit: Use .env filesMarco Portillohttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1197224542020-08-06T11:04:44Z2020-08-06T11:04:44ZI am having a similar problem but I have a real react portlet project instead of the adapting one. My project is deploying only dev mode jar file to the Liferay server, and I see not option to create a production build instead. I have checked my portlet with the react developer tools chrome extension and it says I have a dev mode.How can I create and deploy a production build? I am using react 16.8.6 and Liferay 7.2, also I created the project using Liferay JS Toolkit. I also posted the question in the forum <a href="https://liferay.dev/forums/-/message_boards/message/119712435">here</a>.<br /><br />This is the message I get from the react developer tools from Chrome:<br /><img src="https://user-images.githubusercontent.com/21960445/87949733-b0ee2380-caa6-11ea-9fbb-ea6f03762794.png" alt="image" /><br /><br />What should I do? I have been struggling with this for few weeks now and I don't really know what to do, I apprecially your help.Marco Portillo2020-08-06T11:04:44ZRE: liferay-npm-bundler/liferay-js-toolkit: Use .env filesIván Zaera Avellónhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1187261162020-03-12T08:23:29Z2020-03-12T08:23:29ZHow about a pull request instead of a fork? I can help you with any doubts you have and everybody would benefit from what you do...<br /><br />Regarding the feature, I haven't investigated it, so I don't know how it should be done exactly, but I suppose there must be some way of retaining the production output while injecting development/staging/whatever configuration to the code being built. But I'm no expert in create-react-app and haven't looked at it yet :-(.<br /><br />However, if you feel it is possible and know how to do it there should be no problem in integrating it in the bundler. The only prerequisite, as I said, is that the output looks like a production build, not that the code in the webpack bundles is production code.Iván Zaera Avellón2020-03-12T08:23:29ZRE: liferay-npm-bundler/liferay-js-toolkit: Use .env filesSascha Hofrichterhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1187233082020-03-12T06:48:43Z2020-03-12T06:48:43ZHi Ivan,<br />If I understand you correctly, that there is no option to use another .env file for the build process. <br />That's pretty bad. <br />OK. Another idea is to create a fork of the liferay-js-toolkit project and make our changes to use other .env files.I thank you very much for the information. And have a nice day :-)Sascha Hofrichter2020-03-12T06:48:43ZRE: liferay-npm-bundler/liferay-js-toolkit: Use .env filesIván Zaera Avellónhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1187201112020-03-11T12:42:52Z2020-03-11T12:42:52ZMmm... This is the place where the adapted build calls the native build tools (in your case react-scripts -> <a href="https://github.com/liferay/liferay-js-toolkit/blob/master/packages/liferay-npm-build-support/src/scripts/build/index.js#L31">https://github.com/liferay/liferay-js-toolkit/blob/master/packages/liferay-npm-build-support/src/scripts/build/index.js#L31</a><br />As you can see, we force prod=true for Angular and Vue and don't pass any argument for react (because production is the default). Other than that, we are just calling the "build" npm script so you can put anything you want there as long as when it is finished, a react production build is put in the output folder for liferay-npm-bundler to take on an adapt it.<br />As I said, the bundler only knows how to adapt webpack bundles created in the same format of a production build, but it doesn't rely on any other thing. I mean, it doesn't care about what's inside the bundles.<br />If you are curious about what the bundler does to adapt the native build, you can have a look at this bundler's preset -> <a href="https://github.com/liferay/liferay-js-toolkit/blob/master/packages/liferay-npm-bundler-preset-create-react-app/config.json,">https://github.com/liferay/liferay-js-toolkit/blob/master/packages/liferay-npm-bundler-preset-create-react-app/config.json,</a> which may give you an idea of what steps are needed and why they assume that the build is of production type.<br />Hope that helps.Iván Zaera Avellón2020-03-11T12:42:52ZRE: liferay-npm-bundler/liferay-js-toolkit: Use .env filesSascha Hofrichterhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1187148482020-03-11T10:51:34Z2020-03-11T10:51:34ZHi Ivan, <br />thanks for your information. Well, that's too bad. First of all, I'm fine with that the js-toolkit makes a production build. But we have a multi stage system (development, staging and production) and want to deploy the React apps automatically by a CI/CD server. And for this we need the opportunity to build the React app with different environment variables. And can't see any solution for this problem, right?Sascha Hofrichter2020-03-11T10:51:34ZRE: liferay-npm-bundler/liferay-js-toolkit: Use .env filesIván Zaera Avellónhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1187157582020-03-11T09:19:23Z2020-03-11T09:19:23ZHi Sascha:<br />If you are adapting a React app (as opposed to creating a real portlet -> <a href="https://github.com/liferay/liferay-js-toolkit/wiki/How-to-use-generator-liferay-js">https://github.com/liferay/liferay-js-toolkit/wiki/How-to-use-generator-liferay-js</a>) there's no way to create a non-production build. <br />This is because the non-production builds generate a very different structure from that of production ones which would need to be adapted in a different way.<br />However, you can use React's native tools to test your application and, when you are sure it works, make the production build and deploy it to Liferay. That is the intended way to use it, as adaptation is only a helper for people who already own a codebase targeting other platforms in addition to Liferay.<br />If you need more functionality then you should consider moving your project from an adapted React app to a real React portlet project, as linked above.Iván Zaera Avellón2020-03-11T09:19:23Zliferay-npm-bundler/liferay-js-toolkit: Use .env filesSascha Hofrichterhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1187086562020-03-10T16:29:45Z2020-03-10T16:29:45ZHey Guys,<br />it's time to ask the community. I'm stuck at developing a React app in Liferay 7.3.0-GA1. I've created a React app and run the Liferay JS Generator after that. All things are fine. The OSGi bundle will be created and is deployable (great!). But now, I need to set up some environment variables to use them in my JS-code. My first idea was: 'Hey, create some .env-files like: .env.development, .env.production and so on'. Now I'm in trouble with the liferay-npm-bundler or the liferay-js-toolkit. At the github page of the liferay-js-toolkit is a note, which