react icon indicating copy to clipboard operation
react copied to clipboard

Disable warning about minified copy of the development build

Open japgolly opened this issue 10 years ago • 36 comments

Hello. Since upgrading to v15 I get this all over the place in my unit tests:

Warning: It looks like you're using a minified copy of the development build of React. When deploying React apps to production, make sure to use the production build which skips development warnings and is faster. See https://fb.me/react-minification for more details.

This warning makes sense in prod but in my case, my toolchain is a little different; I use React with Scala and build a special test-deps.js containing all external JS required by unit tests. Minimising it means it loads faster and so I end up with a valid case for a minimisation of the React dev.

Is there a way to remove this warning? It appears a heap of times as my tests are concurrent.

japgolly avatar Apr 11 '16 08:04 japgolly

Is there a way to remove this warning?

Currently, no. One of the things that's somewhere on the roadmap is to make it easier to opt-in/out of specific warnings but there hasn't been a lot of motion on that. Maybe there's something we can do specifically for that warning though...

zpao avatar Apr 11 '16 21:04 zpao

@zpao i have this warning with NODE_ENV=production

dangreen avatar Apr 14 '16 07:04 dangreen

if use webpack,add those code when deploy

new webpack.DefinePlugin({
  "process.env": { 
     NODE_ENV: JSON.stringify("production") 
   }
})

nodeman777 avatar Apr 19 '16 08:04 nodeman777

@nodeman777 I've add that code in webpack plugins, but the warning still exit.

dy86 avatar Apr 19 '16 14:04 dy86

The issue reported here is specifically about minifying non-production React. If you have problems with your toolchain creating a production build, that's a distinct issue and should be discussed in a new issue (or stack overflow first, as this is not intended to be a support forum).

zpao avatar Apr 19 '16 16:04 zpao

In general, if you are minifying your code on staging to simulate a production environment, you should probably be running the production copy of React just in case there are any subtle differences in the code paths (there shouldn't be, if we did everything right, but you never know and it's that type of bug that can really bite you).

Yep, I agree, but we using NODE_ENV to set environment for app and this describe for app what endpoints/databases/credentials to use in this environment. What is why we need staging. And I think it is not good to use some another environment variable for app to fix warning with react

le0pard avatar Apr 22 '16 17:04 le0pard

Oh I have just got this warning !

ghost avatar Apr 26 '16 02:04 ghost

@japgolly : changed the title from Disable minified copy of the development build to Disable warning about minified copy of the development build ?

ghost avatar Apr 26 '16 02:04 ghost

see here .

ghost avatar Apr 26 '16 02:04 ghost

@vimniky After I read your article , I solved the warning .

zhoou avatar Apr 27 '16 06:04 zhoou

@vimniky Just found you article before and I confirm too that the warning is gone. Thank you!

dxps avatar Apr 28 '16 20:04 dxps

I'm getting this warning with NODE_ENV=development, where it doesn't make any sense. We're not even using minification; we use Browserify to build the app bundle on demand.

atombender avatar Aug 10 '16 17:08 atombender

if you do uglify or any things that minify your code in your webpack config in development mode this warning will be showed for me i have to remove new webpack.optimize.UglifyJsPlugin({mangle: false, compress: {warnings: false}}), in my webpack development config to get rid of this warning

hasangilak avatar Oct 16 '16 14:10 hasangilak

This issue was happening to me when running uglify-js with --compress and/or --mangle params.

0xBADCA7 avatar Nov 18 '16 14:11 0xBADCA7

I am getting this error in NODE_ENV=development, too Is this a bug?

aeruhxi avatar Jan 04 '17 08:01 aeruhxi

i add this "new webpack.DefinePlugin({ "process.env": { NODE_ENV: JSON.stringify("production") } })",but still show Warning: It looks like you're using a minified copy of the development build of React. When deploying React apps to production, make sure to use the production build which skips development warnings and is faster. See https://fb.me/react-minification for more details.

can anyone tell me how to resolve this problem?

jocongmin avatar Mar 08 '17 03:03 jocongmin

Also getting this message in production despite env-ifying

slashwhatever avatar Mar 09 '17 10:03 slashwhatever

I keep getting this even if I added this:

new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': JSON.stringify('production') } })

then run this: "build": "cross-env NODE_ENV=production webpack --progress --colors -p"

even if I run just webpack -p with DefinePlugin settings, still im getting the warning.

zeusbangayan avatar Mar 14 '17 15:03 zeusbangayan

I found that passing -p to webpack fixes this error. Is webpack no longer looking at NODE_ENV?

cythrawll avatar Mar 22 '17 16:03 cythrawll

We don’t plan to relax the warning. If you see it there is a problem in your build. You’re shipping a lot of unnecessary code to your users, and React is also slower in development mode.

We have instructions for all popular bundlers. If you are still having problems, please provide a project and somebody might help you out in this thread.

Cheers!

gaearon avatar Mar 22 '17 17:03 gaearon