<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>liferay-npm-bundler/liferay-js-toolkit: Use .env files</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=118708657" />
  <subtitle>liferay-npm-bundler/liferay-js-toolkit: Use .env files</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=118708657</id>
  <updated>2026-04-04T18:50:41Z</updated>
  <dc:date>2026-04-04T18:50:41Z</dc:date>
  <entry>
    <title>RE: liferay-npm-bundler/liferay-js-toolkit: Use .env files</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119756585" />
    <author>
      <name>Iván Zaera Avellón</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119756585</id>
    <updated>2020-08-13T10:08:38Z</updated>
    <published>2020-08-13T10:08:38Z</published>
    <summary type="html">AFAIK you just need to play with the NODE_ENV environment variable. So you could run &amp;#39;NODE_ENV=production npm run build&amp;#39; , for example.</summary>
    <dc:creator>Iván Zaera Avellón</dc:creator>
    <dc:date>2020-08-13T10:08:38Z</dc:date>
  </entry>
  <entry>
    <title>RE: liferay-npm-bundler/liferay-js-toolkit: Use .env files</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119722454" />
    <author>
      <name>Marco Portillo</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119722454</id>
    <updated>2020-08-06T11:04:44Z</updated>
    <published>2020-08-06T11:04:44Z</published>
    <summary type="html">I 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 &lt;a href="https://liferay.dev/forums/-/message_boards/message/119712435"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;This is the message I get from the react developer tools from Chrome:&lt;br /&gt;&lt;img src="https://user-images.githubusercontent.com/21960445/87949733-b0ee2380-caa6-11ea-9fbb-ea6f03762794.png"  alt="image" /&gt;&lt;br /&gt;&lt;br /&gt;What should I do? I have been struggling with this for few weeks now and I don&amp;#39;t really know what to do, I apprecially your help.</summary>
    <dc:creator>Marco Portillo</dc:creator>
    <dc:date>2020-08-06T11:04:44Z</dc:date>
  </entry>
  <entry>
    <title>RE: liferay-npm-bundler/liferay-js-toolkit: Use .env files</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118726116" />
    <author>
      <name>Iván Zaera Avellón</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118726116</id>
    <updated>2020-03-12T08:23:29Z</updated>
    <published>2020-03-12T08:23:29Z</published>
    <summary type="html">How 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...&lt;br /&gt;&lt;br /&gt;Regarding the feature, I haven&amp;#39;t investigated it, so I don&amp;#39;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&amp;#39;m no expert in create-react-app and haven&amp;#39;t looked at it yet :-(.&lt;br /&gt;&lt;br /&gt;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.</summary>
    <dc:creator>Iván Zaera Avellón</dc:creator>
    <dc:date>2020-03-12T08:23:29Z</dc:date>
  </entry>
  <entry>
    <title>RE: liferay-npm-bundler/liferay-js-toolkit: Use .env files</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118723308" />
    <author>
      <name>Sascha Hofrichter</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118723308</id>
    <updated>2020-03-12T06:48:43Z</updated>
    <published>2020-03-12T06:48:43Z</published>
    <summary type="html">Hi Ivan,&lt;br /&gt;If I understand you correctly, that there is no option to use another .env file for the build process. &lt;br /&gt;That&amp;#39;s pretty bad. &lt;br /&gt;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 :-)</summary>
    <dc:creator>Sascha Hofrichter</dc:creator>
    <dc:date>2020-03-12T06:48:43Z</dc:date>
  </entry>
  <entry>
    <title>RE: liferay-npm-bundler/liferay-js-toolkit: Use .env files</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118720111" />
    <author>
      <name>Iván Zaera Avellón</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118720111</id>
    <updated>2020-03-11T12:42:52Z</updated>
    <published>2020-03-11T12:42:52Z</published>
    <summary type="html">Mmm... This is the place where the adapted build calls the native build tools (in your case react-scripts -&amp;gt; &lt;a href="https://github.com/liferay/liferay-js-toolkit/blob/master/packages/liferay-npm-build-support/src/scripts/build/index.js#L31"&gt;https://github.com/liferay/liferay-js-toolkit/blob/master/packages/liferay-npm-build-support/src/scripts/build/index.js#L31&lt;/a&gt;&lt;br /&gt;As you can see, we force prod=true for Angular and Vue and don&amp;#39;t pass any argument for react (because production is the default). Other than that, we are just calling the &amp;#34;build&amp;#34; 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.&lt;br /&gt;As I said, the bundler only knows how to adapt webpack bundles created in the same format of a production build, but it doesn&amp;#39;t rely on any other thing. I mean, it doesn&amp;#39;t care about what&amp;#39;s inside the bundles.&lt;br /&gt;If you are curious about what the bundler does to adapt the native build, you can have a look at this bundler&amp;#39;s preset -&amp;gt; &lt;a href="https://github.com/liferay/liferay-js-toolkit/blob/master/packages/liferay-npm-bundler-preset-create-react-app/config.json,"&gt;https://github.com/liferay/liferay-js-toolkit/blob/master/packages/liferay-npm-bundler-preset-create-react-app/config.json,&lt;/a&gt; which may give you an idea of what steps are needed and why they assume that the build is of production type.&lt;br /&gt;Hope that helps.</summary>
    <dc:creator>Iván Zaera Avellón</dc:creator>
    <dc:date>2020-03-11T12:42:52Z</dc:date>
  </entry>
  <entry>
    <title>RE: liferay-npm-bundler/liferay-js-toolkit: Use .env files</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118714848" />
    <author>
      <name>Sascha Hofrichter</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118714848</id>
    <updated>2020-03-11T10:51:34Z</updated>
    <published>2020-03-11T10:51:34Z</published>
    <summary type="html">Hi Ivan, &lt;br /&gt;thanks for your information. Well, that&amp;#39;s too bad. First of all, I&amp;#39;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&amp;#39;t see any solution for this problem, right?</summary>
    <dc:creator>Sascha Hofrichter</dc:creator>
    <dc:date>2020-03-11T10:51:34Z</dc:date>
  </entry>
  <entry>
    <title>RE: liferay-npm-bundler/liferay-js-toolkit: Use .env files</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118715758" />
    <author>
      <name>Iván Zaera Avellón</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118715758</id>
    <updated>2020-03-11T09:19:23Z</updated>
    <published>2020-03-11T09:19:23Z</published>
    <summary type="html">Hi Sascha:&lt;br /&gt;If you are adapting a React app (as opposed to creating a real portlet -&amp;gt; &lt;a href="https://github.com/liferay/liferay-js-toolkit/wiki/How-to-use-generator-liferay-js"&gt;https://github.com/liferay/liferay-js-toolkit/wiki/How-to-use-generator-liferay-js&lt;/a&gt;) there&amp;#39;s no way to create a non-production build. &lt;br /&gt;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.&lt;br /&gt;However, you can use React&amp;#39;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.&lt;br /&gt;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.</summary>
    <dc:creator>Iván Zaera Avellón</dc:creator>
    <dc:date>2020-03-11T09:19:23Z</dc:date>
  </entry>
  <entry>
    <title>liferay-npm-bundler/liferay-js-toolkit: Use .env files</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118708656" />
    <author>
      <name>Sascha Hofrichter</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118708656</id>
    <updated>2020-03-10T16:29:45Z</updated>
    <published>2020-03-10T16:29:45Z</published>
    <summary type="html">Hey Guys,&lt;br /&gt;it&amp;#39;s time to ask the community. I&amp;#39;m stuck at  developing a React app in Liferay 7.3.0-GA1. I&amp;#39;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: &amp;#39;Hey, create some .env-files like: .env.development, .env.production and so on&amp;#39;. Now I&amp;#39;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 says that the adapter of the toolkit will always make a &amp;#39;production build&amp;#39; (&lt;a href="https://github.com/liferay/liferay-js-toolkit/wiki/How-to-adapt-most-popular-frameworks-projects"&gt;github-page&lt;/a&gt;). But I need also a &amp;#39;development&amp;#39; or &amp;#39;staging&amp;#39; build. The documentation is not very helpful and I have no idea to bypass the production build. &lt;br /&gt;Has anybody a solution to make a development build? </summary>
    <dc:creator>Sascha Hofrichter</dc:creator>
    <dc:date>2020-03-10T16:29:45Z</dc:date>
  </entry>
</feed>
