I'm using webpack to build my react project ( "react": "^0.14.6" ), and somehow it is throwing production is not defined ( ReferenceError ) in ReactPerf. Because in my webpack setting, I was injecting the NODE_ENV ( which was working fine before ), any advice on that ?


DefinePlugin just substitutes what you specify as the value. You are specifying 'production', so it embeds the contents of the string (production) in your code, and it blows up. The correct configuration for that key is NODE_ENV: "'production'" (notice the apostrophes inside the quotes!) This way you Webpack will put a JS string in your code, and it will work.
You鈥檒l notice that most example configurations use { NODE_ENV: JSON.stringify('production') }. This is exactly the reason why they鈥檙e doing it. JSON.stringify('production') becomes a string containing "production". But you can specify it in the raw '"production"' or "'production'" form if you鈥檇 like.
TLDR: Replace NODE_ENV: "production" with NODE_ENV: "'production'" in your config.
Most helpful comment
DefinePluginjust substitutes what you specify as the value. You are specifying'production', so it embeds the contents of the string (production) in your code, and it blows up. The correct configuration for that key isNODE_ENV: "'production'"(notice the apostrophes inside the quotes!) This way you Webpack will put a JS string in your code, and it will work.You鈥檒l notice that most example configurations use
{ NODE_ENV: JSON.stringify('production') }. This is exactly the reason why they鈥檙e doing it.JSON.stringify('production')becomes a string containing"production". But you can specify it in the raw'"production"'or"'production'"form if you鈥檇 like.TLDR: Replace
NODE_ENV: "production"withNODE_ENV: "'production'"in your config.