Use production build of react in meteor app


#1

Hello meteor community.

I’m sorry if the answer to my question is super obvious, but i already spent a significant amount of time trying to solve this:

Let’s assume a newly created, blank meteor app with only the 2 react packages (react and react-dom) added.

meteor npm install --save react react-dom

What additional steps do i have to take to make meteor use the production build of react instead of the development build? I have the react developer tools installed and when i open my app on localhost, i see this symbol:

which indicates that i’m using reacts development build.

Best regards and thanks in advance


#2

I’m getting this too, I think its just appeared.

There is another thread on this, worth keeping an eye on it…


#3

Try to check Meteor in production: meteor --production as this reflects what you will deploy.


#4

Thanks guys, the .babelrc answer of pierreeric in the linked thread solved the issue.
My second mistake was indeed that i did not test this locally in (simulated) production mode.

However: Maybe it’s just me, but i wish this could be done in a more elegant way :wink:


#5

I tried the --production flag, and it did not turn React into production mode.

I’m just starting learning React so for me it doesn’t really matter at the moment anyway. This seems like the sort of thing that Meteor ought to handle magically though.


#6

I’ve added a .babelrc as per the other thread, but I’m getting the following error…

Warning: Each child in an array or iterator should have a unique “key” prop. Check the render method of <compentName>

The error is being triggered by a Redux-Form Field component which has a spread operator for field attributes.

I’m still getting to grips with React and production deployments. I assume that I need my app to understand spread operators when being built for production? Any suggestions gratefully received.


#7

Hi guys, any news on this one? Seeing it in my app, too


#8

In development, the development build of react is also being used. Once you build for production, the correct production parameter is also passed to react.


#9

Ok, I guess it has to do with my mup setting for my staging, where I set NODE_ENV: 'staging'.

Thanks for the update!:grinning: